n = int(eval(input()))

tp = hp = 0



for nc in range(n):

    (tc, hc) = input().split()

    if tc == hc:

        tp += 1

        hp += 1

    elif tc > hc:

        tp += 3

    elif tc < hc:

        hp += 3



print((tp, hp))
n = int(eval(input()))



taro = 0

hanako = 0

for ni in range(n):

    t, h = input().split()



    if t < h:

        hanako += 3

    elif t > h:

        taro += 3

    else:

        hanako += 1

        taro += 1



print((taro, hanako))
n = int(eval(input()))
tp = hp = 0
for nc in range(n):
    (tc, hc) = input().split()
    if tc == hc:
        tp += 1
        hp += 1
    elif tc > hc:
        tp += 3
    elif tc < hc:
        hp += 3
print((tp, hp))

n = int(eval(input()))
taro = 0
hanako = 0
for ni in range(n):
    t, h = input().split()
    if t < h:
        hanako += 3
    elif t > h:
        taro += 3
    else:
        hanako += 1
        taro += 1
print((taro, hanako))

-tp = hp = 0 -for nc in range(n): -    (tc, hc) = input().split() -    if tc == hc: -        tp += 1 -        hp += 1 -    elif tc > hc: -        tp += 3 -    elif tc < hc: -        hp += 3 -print((tp, hp)) +taro = 0 +hanako = 0 +for ni in range(n): +    t, h = input().split() +    if t < h: +        hanako += 3 +    elif t > h: +        taro += 3 +    else: +        hanako += 1 +        taro += 1 +print((taro, hanako))