import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        if (!sc.hasNextInt()) {
            System.out.println("Invalid input");
            return;
        }

        int n = sc.nextInt();
        sc.nextLine(); // consume newline

        // If catalog is empty initially
        if (n <= 0) {
            System.out.println("Invalid input");
            return;
        }

        // Store products in LinkedHashMap to preserve order
        Map<String, Integer> catalog = new LinkedHashMap<>();

        for (int i = 0; i < n; i++) {
            String line = sc.nextLine().trim();

            // Find last space to separate product name and price
            int lastSpace = line.lastIndexOf(" ");
            if (lastSpace == -1) {
                System.out.println("Invalid input");
                return;
            }

            String name = line.substring(0, lastSpace).trim();
            int price = Integer.parseInt(line.substring(lastSpace + 1).trim());

            catalog.put(name, price);
        }

        // Product to remove
        if (!sc.hasNextLine()) {
            System.out.println("Invalid input");
            return;
        }
        String removeProduct = sc.nextLine().trim();

        if (!catalog.containsKey(removeProduct)) {
            System.out.println(-1);
            return;
        }

        // Remove the product
        catalog.remove(removeProduct);

        // If everything removed, still valid → print nothing
        for (Map.Entry<String, Integer> entry : catalog.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
    }
}