import java.util.*;

public class Main {
    public static boolean isSubMap(Map<String, Integer> sub, Map<String, Integer> main) {
        for (Map.Entry<String, Integer> entry : sub.entrySet()) {
            String key = entry.getKey();
            Integer value = entry.getValue();

            if (!main.containsKey(key) || !main.get(key).equals(value)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 1️⃣ Read main map
        int n1 = sc.nextInt();
        if (n1 <= 0) {
            System.out.println("Invalid input");
            return;
        }
        Map<String, Integer> mainMap = new HashMap<>();
        for (int i = 0; i < n1; i++) {
            String key = sc.next();
            int value = sc.nextInt();
            mainMap.put(key, value);
        }

        // 2️⃣ Read submap
        int n2 = sc.nextInt();
        if (n2 <= 0) {
            System.out.println("Invalid input");
            return;
        }
        Map<String, Integer> subMap = new HashMap<>();
        for (int i = 0; i < n2; i++) {
            String key = sc.next();
            int value = sc.nextInt();
            subMap.put(key, value);
        }

        // 3️⃣ p
        boolean result = isSubMap(subMap, mainMap);
        System.out.println(result ? "True" : "False");

        sc.close();
    }
}
