import java.util.*;

public class ProductCatalogManager {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

    
        if (n <= 0) {
            System.out.println("Invalid input");
            return;
        }

       
        LinkedHashMap<String, Integer> catalog = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String productName = sc.next();
            int price = sc.nextInt();
            catalog.put(productName, price);
        }

        
        String productToRemove = sc.next();

      
        if (!catalog.containsKey(productToRemove)) {
            System.out.println("-1");
            return;
        }

    
        catalog.remove(productToRemove);

        
        if (catalog.isEmpty()) {
            System.out.println("Invalid input");
            return;
        }

        
        for (Map.Entry<String, Integer> entry : catalog.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
    }
}


