summaryrefslogtreecommitdiffstats
path: root/Main/Python/2022/S2.py
blob: 44096037fa6032a64d63be8e4a79d19bf1132a2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
x = int(input())
same = set()
for i in range(x):
    a,b = input().split()
    same.add((a,b))


diff = set()
y = int(input())
for i in range(y):
    a,b = input().split()
    diff.add((a,b))

groups = set()
g = int(input())
for i in range(g):
    a,b,c = input().split()
    groups.add((a,b))
    groups.add((b,c))
    groups.add((a,c))

output = 0
for i in same:
    a,b = i
    if not ((a,b) in groups or (b,a) in groups):
        output += 1
for i in diff:
    a,b = i
    if ((a,b) in groups) or ((b,a) in groups):
        output += 1

print(output)