import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // Check n
        if (!sc.hasNextInt()) {
            System.out.println("Invalid input");
            return;
        }

        int n = sc.nextInt();
        sc.nextLine(); // consume newline

        // Check constraints
        if (n <= 0 || n > 100) {
            System.out.println("Invalid input");
            return;
        }

        // Read catalog
        Map<String, Integer> catalog = new LinkedHashMap<>();
        for (int i = 0; i < n; i++) {
            if (!sc.hasNext()) {
                System.out.println("Invalid input");
                return;
            }
            String name = sc.next();
            if (!sc.hasNextInt()) {
                System.out.println("Invalid input");
                return;
            }
            int price = sc.nextInt();
            catalog.put(name, price);
        }

        // Product to remove
        if (!sc.hasNext()) {
            System.out.println("Invalid input");
            return;
        }
        String removeProduct = sc.next();

        // If product doesn't exist
        if (!catalog.containsKey(removeProduct)) {
            System.out.println("-1");
            return;
        }

        // Remove product
        catalog.remove(removeProduct);

        // Print remaining (if empty → just nothing)
        for (Map.Entry<String, Integer> entry : catalog.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
    }
}
