def judge(w1, w2):

    la = len(w1)

    lb = len(w2)

    for i in range(min(la,lb)):

        if w1[i] > w2[i]: return 1

        elif w1[i] < w2[i]: return 2

    if la > lb: return 1

    elif la < lb: return 2

    else: return 0



s = [0, 0, 0]

loop = int(input())

for i in range(loop):

    w = input().split()

    tmp = judge(*w)

    if tmp == 0:

        s[1] += 1

        s[2] += 1

    else:

        s[tmp] += 3

print(s[1], s[2])
s = [0, 0, 0]

loop = int(input())

for i in range(loop):

    w1, w2 = input().split()

    tmp = 1 - cmp(w1, w2)

    if tmp == 1:

        s[0] += 1

        s[2] += 1

    else:

        s[tmp] += 3

print(s[0], s[2])
def judge(w1, w2):
    la = len(w1)
    lb = len(w2)
    for i in range(min(la, lb)):
        if w1[i] > w2[i]:
            return 1
        elif w1[i] < w2[i]:
            return 2
    if la > lb:
        return 1
    elif la < lb:
        return 2
    else:
        return 0


s = [0, 0, 0]
loop = int(input())
for i in range(loop):
    w = input().split()
    tmp = judge(*w)
    if tmp == 0:
        s[1] += 1
        s[2] += 1
    else:
        s[tmp] += 3
print(s[1], s[2])

s = [0, 0, 0]
loop = int(input())
for i in range(loop):
    w1, w2 = input().split()
    tmp = 1 - cmp(w1, w2)
    if tmp == 1:
        s[0] += 1
        s[2] += 1
    else:
        s[tmp] += 3
print(s[0], s[2])

-def judge(w1, w2): -    la = len(w1) -    lb = len(w2) -    for i in range(min(la, lb)): -        if w1[i] > w2[i]: -            return 1 -        elif w1[i] < w2[i]: -            return 2 -    if la > lb: -        return 1 -    elif la < lb: -        return 2 -    else: -        return 0 - - -    w = input().split() -    tmp = judge(*w) -    if tmp == 0: -        s[1] += 1 +    w1, w2 = input().split() +    tmp = 1 - cmp(w1, w2) +    if tmp == 1: +        s[0] += 1 -print(s[1], s[2]) +print(s[0], s[2])