import java.util.*;

public class Main {
    static class Product {
        String name;
        int price;
        Product(String n, int p) { name = n; price = p; }
    }
    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 end-of-line

        if (n <= 0) {
            System.out.println("Invalid input");
            return;
        }

        List<Product> catalog = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String line = sc.nextLine().trim();
            // find last space to split name & price
            int idx = line.lastIndexOf(' ');
            if (idx < 0) {
                // malformed line—skip or handle as needed
                continue;
            }
            String name = line.substring(0, idx);
            int price = Integer.parseInt(line.substring(idx + 1));
            catalog.add(new Product(name, price));
        }

        String toRemove = sc.nextLine().trim();
        int removeIndex = -1;
        for (int i = 0; i < catalog.size(); i++) {
            if (catalog.get(i).name.equals(toRemove)) {
                removeIndex = i;
                break;
            }
        }

        if (removeIndex < 0) {
            System.out.println("-1");
            return;
        }

        catalog.remove(removeIndex);
        for (Product p : catalog) {
            System.out.println(p.name + " " + p.price);
        }
    }
}