import java.util.*;

public class ProductCatalog {
    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;
        }

        // Use LinkedHashMap to preserve insertion order
        Map<String, Integer> catalog = new LinkedHashMap<>();

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

            // Find last space → split name & price
            int lastSpace = line.lastIndexOf(" ");
            if (lastSpace == -1) {
                System.out.println("Invalid input");
                return;
            }
            String name = line.substring(0, lastSpace);
            int price = Integer.parseInt(line.substring(lastSpace + 1));

            catalog.put(name, price);
        }

        String productToRemove = sc.nextLine().trim();

        // If product does not exist
        if (!catalog.containsKey(productToRemove)) {
            System.out.println("-1");
            return;
        }

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

        // Print remaining products
        for (Map.Entry<String, Integer> entry : catalog.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
    }
}