taro = 0

hanako = 0

n = int(eval(input()))

for _ in range(n):

    taro_card, hanako_card = input().split()

    if taro_card > hanako_card:

        taro += 3

    elif taro_card < hanako_card:

        hanako += 3

    else:

        taro += 1

        hanako += 1

print((taro, hanako))
taro_point = 0

hanako_point = 0



n = int(eval(input()))

for i in range(n):

    taro, hanako = input().split()

    if taro == hanako:

        taro_point += 1

        hanako_point += 1

    elif taro > hanako:

        taro_point += 3

    else:

        hanako_point += 3

print((taro_point, hanako_point))



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

taro_point = 0
hanako_point = 0
n = int(eval(input()))
for i in range(n):
    taro, hanako = input().split()
    if taro == hanako:
        taro_point += 1
        hanako_point += 1
    elif taro > hanako:
        taro_point += 3
    else:
        hanako_point += 3
print((taro_point, hanako_point))

-taro = 0 -hanako = 0 +taro_point = 0 +hanako_point = 0 -for _ in range(n): -    taro_card, hanako_card = input().split() -    if taro_card > hanako_card: -        taro += 3 -    elif taro_card < hanako_card: -        hanako += 3 +for i in range(n): +    taro, hanako = input().split() +    if taro == hanako: +        taro_point += 1 +        hanako_point += 1 +    elif taro > hanako: +        taro_point += 3 -        taro += 1 -        hanako += 1 -print((taro, hanako)) +        hanako_point += 3 +print((taro_point, hanako_point))