point_t = 0

point_h = 0

n = int(eval(input()))

for i in range(n):

    card_t, card_h = input().split()

    if card_t > card_h:

        point_t += 3

    if card_t < card_h:

        point_h += 3

    if card_t == card_h:

        point_t += 1

        point_h += 1

print((point_t, point_h))
n = int(eval(input()))

T_point = 0

H_point = 0

for i in range(n):

    Taro, Hanako = input().split()

    if Taro > Hanako:

        T_point += 3

    elif Hanako > Taro:

        H_point += 3

    else:

        T_point += 1

        H_point += 1

print((T_point, H_point))
point_t = 0
point_h = 0
n = int(eval(input()))
for i in range(n):
    card_t, card_h = input().split()
    if card_t > card_h:
        point_t += 3
    if card_t < card_h:
        point_h += 3
    if card_t == card_h:
        point_t += 1
        point_h += 1
print((point_t, point_h))

n = int(eval(input()))
T_point = 0
H_point = 0
for i in range(n):
    Taro, Hanako = input().split()
    if Taro > Hanako:
        T_point += 3
    elif Hanako > Taro:
        H_point += 3
    else:
        T_point += 1
        H_point += 1
print((T_point, H_point))

-point_t = 0 -point_h = 0 +T_point = 0 +H_point = 0 -    card_t, card_h = input().split() -    if card_t > card_h: -        point_t += 3 -    if card_t < card_h: -        point_h += 3 -    if card_t == card_h: -        point_t += 1 -        point_h += 1 -print((point_t, point_h)) +    Taro, Hanako = input().split() +    if Taro > Hanako: +        T_point += 3 +    elif Hanako > Taro: +        H_point += 3 +    else: +        T_point += 1 +        H_point += 1 +print((T_point, H_point))