import java.util.*;

public class ProductCatalog {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        // Check if we have integer input
        if (!scanner.hasNextInt()) {
            System.out.println("Invalid input");
            return;
        }
        
        int n = scanner.nextInt();
        scanner.nextLine(); // Consume the newline
        
        // Handle negative n values (constraints allow -100 ≤ n ≤ 100)
        if (n < 0) {
            System.out.println("Invalid input");
            return;
        }
        
        // Handle n = 0 (empty catalog)
        if (n == 0) {
            System.out.println("Invalid input");
            return;
        }
        
        Map<String, Integer> catalog = new LinkedHashMap<>();
        
        // Read n products
        for (int i = 0; i < n; i++) {
            if (!scanner.hasNextLine()) {
                System.out.println("Invalid input");
                return;
            }
            
            String line = scanner.nextLine().trim();
            if (line.isEmpty()) {
                System.out.println("Invalid input");
                return;
            }
            
            // Split the line into parts
            String[] parts = line.split(" ");
            
            // The last part should be the price, the rest is the product name
            if (parts.length < 2) {
                System.out.println("Invalid input");
                return;
            }
            
            // Extract price (last element)
            String priceStr = parts[parts.length - 1];
            int price;
            try {
                price = Integer.parseInt(priceStr);
            } catch (NumberFormatException e) {
                System.out.println("Invalid input");
                return;
            }
            
            // Extract product name (all parts except the last)
            StringBuilder productName = new StringBuilder();
            for (int j = 0; j < parts.length - 1; j++) {
                if (j > 0) productName.append(" ");
                productName.append(parts[j]);
            }
            
            catalog.put(productName.toString(), price);
        }
        
        // Read product to remove
        if (!scanner.hasNextLine()) {
            System.out.println("Invalid input");
            return;
        }
        
        String productToRemove = scanner.nextLine().trim();
        
        // Check if product exists
        if (!catalog.containsKey(productToRemove)) {
            System.out.println("-1");
            return;
        }
        
        // Remove the product
        catalog.remove(productToRemove);
        
        // Display remaining products (even if catalog becomes empty)
        for (Map.Entry<String, Integer> entry : catalog.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
        
        // If catalog becomes empty after removal, no output is needed
        // (the problem doesn't specify what to do in this case)
    }
}