Title: Card Game

Taro and Hanako are playing a card game. Each has "n" cards, and they play "n" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.

Write a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.

Input:
The first line contains the number of cards "n". The following "n" lines contain the cards for "n" turns, with the first string representing Taro's card and the second one representing Hanako's card.

Constraints:
- n ≤ 1000
- The length of the string ≤ 100

Output:
Print the final scores of Taro and Hanako respectively, with a single space character between them.

Sample Input:
3
cat dog
fish fish
lion tiger

Sample Output:
1 7

# Buggy version:
#coding: UTF-8

n = int(input())
point_t = 0
point_h = 0

for i in range(n):
    cards = list(map(str, input().split()))
    taro = cards[0]
    hanako = cards[1]
    if taro > hanako:
        point_h += 3
    elif taro < hanako:
        point_t += 3
    else:
        point_t += 1
        point_h += 1

print(point_t, point_h)


# Fixed version:
#coding: UTF-8

n = int(input())
point_t = 0
point_h = 0

for i in range(n):
    cards = list(map(str, input().split()))
    taro = cards[0]
    hanako = cards[1]
    if taro < hanako:
        point_h += 3
    elif taro > hanako:
        point_t += 3
    else:
        point_t += 1
        point_h += 1

print(point_t, point_h)

# Buggy version:
n = int(input())
tp = 0
hp = 0
for i in range(n):
    tarou, hanako = map(str,input().split())
    if(tarou > hanko):
        tp += 3
    elif(tarou < hanako):
        hp += 3
    else:
        tp += 1
        hp += 1
print("%d %d" %(tp,hp))


# Fixed version:
n = int(input())
tp = 0
hp = 0
for i in range(n):
    tarou, hanako = map(str,input().split())
    if(tarou > hanako):
        tp += 3
    elif(tarou < hanako):
        hp += 3
    else:
        tp += 1
        hp += 1
print("%d %d" %(tp,hp))

# Buggy version:
taro = 0
hanako = 0
n = int(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)
print(taro, hanako)

# Fixed version:
taro = 0
hanako = 0
n = int(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)

# Buggy version:
# coding: utf-8


n = int(input())

scores = [0,0]

for i in range(n):
    card = input().split()
    first_card = card[0]
    card.sort()
    print(card)
    print(first_card)
    if (card[0] == card[1]):
        scores[0] += 1
        scores[1] += 1
    elif(first_card == card[0]):
        scores[1] += 3
    else:
        scores[0] += 3

print(scores[0], scores[1])

# Fixed version:
# coding: utf-8


n = int(input())

scores = [0,0]

for i in range(n):
    card = input().split()
    first_card = card[0]
    card.sort()
    if (card[0] == card[1]):
        scores[0] += 1
        scores[1] += 1
    elif(first_card == card[0]):
        scores[1] += 3
    else:
        scores[0] += 3

print(scores[0], scores[1])

# Buggy version:
point_a,point_b = 0,0
for i in range(int(input())):
	k =[]
	a,b = input().split()
	k = [[i,j] for i,j in zip(a,b) if i != j]
	if k == []:
		if len(a) < len(b):
			point_b+=3
		elif len(a) > len(b):
			point_a += 3
		else:
			point_a+=1
			point_b+=1
	elif ord(k[0][0]) < ord(k[0][1]):
		point_b += 3
	else :
		point_a += 3
	print(point_a,point_b)
print(point_a,point_b)

# Fixed version:
point_a,point_b = 0,0
for i in range(int(input())):
	k =[]
	a,b = input().split()
	k = [[i,j] for i,j in zip(a,b) if i != j]
	if k == []:
		if len(a) < len(b):
			point_b+=3
		elif len(a) > len(b):
			point_a += 3
		else:
			point_a+=1
			point_b+=1
	elif ord(k[0][0]) < ord(k[0][1]):
		point_b += 3
	else :
		point_a += 3
print(point_a,point_b)

# Buggy version:
i = int(input())
 
tarou = 0
hanako = 0

for x in range(i):
    a,b = input().split()
    if b > a:
        hanako += 3
    elif a > b:
        tarou += 3
    else:
        hanako += 1
        tarou += 1
    print("{0} {1}".format(tarou, hanako))

# Fixed version:
i = int(input())

tarou = 0
hanako = 0

for x in range(i):
    a,b = input().split()
    if b > a:
        hanako += 3
    elif a > b:
        tarou += 3
    else:
        hanako += 1
        tarou += 1
print("{0} {1}".format(tarou, hanako))

# Buggy version:
n = int(input())
Taro = 0
Hanako = 0
for i in range(n):
    t,h = input().split()
    for j in range(min(len(t),len(h))):
        if t == h:
            Hanako += 1
            Taro += 1
            break
        if ord(t[j:j+1]) > ord(h[j:j+1]):
            Taro += 3
            break
        if ord(t[j:j+1]) < ord(h[j:j+1]):
            Hanako += 3
            break
    if len(t) > len(h):
        Taro += 3
    elif len(t) < len(h):
        Hanako += 3
	

print("{} {}".format(Taro,Hanako))

# Fixed version:
n = int(input())
Taro = 0
Hanako = 0

for i in range(n):
    x = 0
    t,h = input().split()
    for j in range(min(len(t),len(h))):
        if t == h:
            Hanako += 1
            Taro += 1
            x = 1 
            break
        if ord(t[j:j+1]) > ord(h[j:j+1]):
            Taro += 3
            x = 1
            break
        if ord(t[j:j+1]) < ord(h[j:j+1]):
            Hanako += 3
            x = 1
            break
    if x == 0:
        if len(t) > len(h):
            Taro += 3
        elif len(t) < len(h):
            Hanako += 3
	

print("{} {}".format(Taro,Hanako))

# Buggy version:
n = int(input())

t_score = 0
h_score = 0


for i in range(n):
 t, h = input().split()
 if t == h:
  t_score += 1
  h_score += 1
  continue
 if len(t) > len(h):
  for j in range(len(h)):
   if ord(t[j]) > ord(h[j]):
    t_score += 3
    break
   elif ord(t[j]) < ord(h[j]):
    h_score += 3
    break
  else:
   h_score += 3
 elif len(t) < len(h):
   for j in range(len(t)):
    if ord(t[j]) > ord(h[j]):
     t_score += 3
     break
    elif ord(t[j]) < ord(h[j]):
     h_score += 3
     break
   else:
    t_score += 3

   
print("{0} {1}".format(t_score, h_score))

# Fixed version:
n = int(input())

t_score = 0
h_score = 0


for i in range(n):
 t, h = input().split()
 if t == h:
  t_score += 1
  h_score += 1
  continue
 if len(t) >= len(h):
  for j in range(len(h)):
   if ord(t[j]) > ord(h[j]):
    t_score += 3
    break
   elif ord(t[j]) < ord(h[j]):
    h_score += 3
    break
  else:
   t_score += 3
 elif len(t) < len(h):
   for j in range(len(t)):
    if ord(t[j]) > ord(h[j]):
     t_score += 3
     break
    elif ord(t[j]) < ord(h[j]):
     h_score += 3
     break
   else:
    h_score += 3

   
print("{0} {1}".format(t_score, h_score))

# Buggy version:
n = int(input())
st, sh = 0, 0
for i in range(n):
    t, h = map(str, input().split())
    if t > h:
        st += 3
    elif t < h:
        sh += 3
    else:
        st += 1
        st += 1
print(st, sh)

# Fixed version:
n = int(input())
st, sh = 0, 0
for i in range(n):
    t, h = map(str, input().split())
    if t > h:
        st += 3
    elif t < h:
        sh += 3
    else:
        st += 1
        sh += 1
print(st, sh)

# Buggy version:
n = int(input())
t_point = 0
h_point = 0
for i in range(n):
    card = input().split()
    print(card)
    taro = card[0]
    card.sort()
    card.reverse()
    print(card)
    if card[0] == card[1]:
        t_point += 1
        h_point += 1
    elif card[0] == taro:
        t_point += 3
    else:
        h_point += 3

print(t_point,h_point)

# Fixed version:
n = int(input())
t_point = 0
h_point = 0
for i in range(n):
    card = input().split()
    taro = card[0]
    card.sort()
    card.reverse()
    if card[0] == card[1]:
        t_point += 1
        h_point += 1
    elif card[0] == taro:
        t_point += 3
    else:
        h_point += 3

print(t_point,h_point)

# Buggy version:
ap,bp = 0
n = int(input())
for i in range(n):
    a,b = input().split()
    if a>b:
        ap+=3
    elif a==b:
        bp+=3
    else:
        bp+=3
    print(ap,bp)

# Fixed version:
ap,bp = 0,0
n = int(input())
for i in range(n):
    a,b = input().split()
    if a>b:
        ap+=3
    elif a==b:
        ap+=1
        bp+=1
    else:
        bp+=3
print(ap,bp)

# Buggy version:
import sys
n = int(input())
p_t = 0
p_h = 0

for i in range(n):
	taro, hanako = input().split()
	if taro == hanako:
		p_t += 1
		p_h += 1
	else:
		l_t = list(taro)
		l_h = list(hanako)
		for j in range(min(len(l_t), len(l_h))):
			if l_t[j] != l_h[j]:
				if ord(l_t[j])<ord(l_h[j]):
					p_h += 3
					print('taro')
					break
				else:
					p_t += 3
					print('hanako')
					break

print(p_t, p_h)

# Fixed version:
import sys
n = int(input())
p_t = 0
p_h = 0

for i in range(n):
	taro, hanako = input().split()
	if taro == hanako:
		p_t += 1
		p_h += 1
	else:
		l_t = list(taro)
		l_h = list(hanako)
		for j in range(min(len(l_t), len(l_h))):
			if l_t[j] != l_h[j]:
				if ord(l_t[j])<ord(l_h[j]):
					p_h += 3
					#print('taro')
					break
				else:
					p_t += 3
					#print('hanako')
					break
			else:
				if j == min(len(l_t), len(l_h))-1:
					if len(l_t)>len(l_h):
						p_t += 3
					else:
						p_h += 3
					

print(p_t, p_h)

# Buggy version:
count = int(input())
Taro_an = []
Hanako_an = []
Ts = 0
Hs = 0
for i in range(count) :
    animal = input().split(" ")
    Taro_an = animal[0]
    Hanako_an = animal[1]
    if Taro_an > Hanako_an :
        Ts += 3
    else :
        if Hanako_an > Taro_an :
            Hs += 3
        else :
            ++Ts, ++Hs
print(Ts,Hs)

# Fixed version:
count = int(input())
Taro_an = []
Hanako_an = []
Ts = 0
Hs = 0
for i in range(count) :
    animal = input().split(" ")
    Taro_an = animal[0]
    Hanako_an = animal[1]
    if Taro_an > Hanako_an :
        Ts += 3
    else :
        if Hanako_an > Taro_an :
            Hs += 3
        else :
            Ts += 1; Hs += 1
print(Ts,Hs)

# Buggy version:
n = int(input())

score_taro, score_hanako = 0, 0
for _ in range(n):
    card_taro, card_hanako = input().split()

    point_taro, point_hanako = 0, 0
    if card_taro == card_hanako:
        score_taro = 1
        score_hanako = 1
        continue
    for i in range(min(len(card_taro), len(card_hanako))):
        if len(card_taro) > len(card_hanako):
            point_taro = 3
        if len(card_taro) < len(card_hanako):
            point_hanako = 3
        if ord(card_taro[i:i+1]) > ord(card_hanako[i:i+1]):
            point_taro = 3
            point_hanako = 0
            break
        if ord(card_taro[i:i+1]) < ord(card_hanako[i:i+1]):
            point_taro = 0
            point_hanako = 3
            break

    score_taro += point_taro
    score_hanako += point_hanako

print("{0} {1}".format(score_taro, score_hanako))

# Fixed version:
n = int(input())

score_taro, score_hanako = 0, 0
for _ in range(n):
    card_taro, card_hanako = input().split()

    point_taro = 0
    point_hanako = 0
    if card_taro == card_hanako:
        score_taro += 1
        score_hanako += 1
        continue
    for i in range(min(len(card_taro), len(card_hanako))):
        if len(card_taro) > len(card_hanako):
            point_taro = 3
        elif len(card_taro) < len(card_hanako):
            point_hanako = 3
        if ord(card_taro[i:i+1]) > ord(card_hanako[i:i+1]):
            point_taro = 3
            point_hanako = 0
            break
        if ord(card_taro[i:i+1]) < ord(card_hanako[i:i+1]):
            point_taro = 0
            point_hanako = 3
            break
    score_taro += point_taro
    score_hanako += point_hanako
print("{0} {1}".format(score_taro, score_hanako))

# Buggy version:
#!/usr/bin/env python

n = int(input())

tScore = 0
hScore = 0

for i in range(n):
    T, H = input().split()
    if T == H:
        tScore += 1
        hScore += 1
    elif T > H:
        hScore +=3
    elif H > T:
        tScore += 3
print("%d %d" % (tScore, hScore))

# Fixed version:
#!/usr/bin/env python

n = int(input())

tScore = 0
hScore = 0

for i in range(n):
    T, H = input().split()
    if T == H:
        tScore += 1
        hScore += 1
    elif T > H:
        tScore += 3
    elif H > T:
        hScore +=3
print("%d %d" % (tScore, hScore))

# Buggy version:
#coding:utf-8

n = int(input().rstrip())
toku =[0,0]
narabe = []

for i in range(n):
    taro, hana = input().rstrip().split()
    if taro == hana:
        toku[0] +=1
        toku[1] +=1

    else:
        narabe = [taro, hana]
        narabe.sort()
        toku[0] += narabe.index(taro)*3
        toku[1] += narabe.index(hana)*3
    
print(" ".join(toku))

# Fixed version:
#coding:utf-8

n = int(input().rstrip())
toku =[0,0]
narabe = []

for i in range(n):
    taro, hana = input().rstrip().split()
    if taro == hana:
        toku[0] +=1
        toku[1] +=1

    else:
        narabe = [taro, hana]
        narabe.sort()
        toku[0] += narabe.index(taro)*3
        toku[1] += narabe.index(hana)*3
    
print(" ".join(list(map(str,toku))))

# Buggy version:
turn=int(input())
ten=[0,0]

for _ in range(turn):
    hikaku = list(map(int,input().split()))
    if hikaku[0] < hikaku[1]:
        ten[1] +=3

    elif hikaku[0] > hikaku[1]:
        ten[0] +=3

    else:
        ten[0]+=1
        ten[1]+=1

print(" ".join(map(str,ten)))

# Fixed version:
turn=int(input())
ten=[0,0]

for _ in range(turn):
    hikaku = input().split()
    if hikaku[0] < hikaku[1]:
        ten[1] +=3

    elif hikaku[0] > hikaku[1]:
        ten[0] +=3

    else:
        ten[0]+=1
        ten[1]+=1

print(" ".join(map(str,ten)))

# Buggy version:
t=0
h=0
for i in range(int(input())):
    l=input().split()
    if l[0]=l[1]:
        t+=1
        h+=1
    elif l[0]>l[1]: t+=3
    else: h+=3
print(t,h)

# Fixed version:
t=0
h=0
for i in range(int(input())):
    l=input().split()
    if l[0]==l[1]:
        t+=1
        h+=1
    elif l[0]>l[1]: t+=3
    else: h+=3
print(t,h)

# Buggy version:
#! python3
# card_game.py

n = int(input())
turns = [input() for i in range(n)]

taro, hanako = 0, 0
for turn in turns:
    t, h = turn.split(' ')
    min_len = len(t) if len(t) <= len(h) else len(h)

    win_flag = 0 # -1: taro, 1: hanako, 0: draw
    for i in range(min_len):
        if ord(t[i]) < ord(h[i]):
            win_flag = 1
        elif ord(h[i]) < ord(t[i]):
            win_flag = -1

    if win_flag == 0:
        if len(t) < len(h):
            win_flag = 1
        elif len(h) < len(t):
            win_flag = -1

    if win_flag == -1:
        taro += 3
    elif win_flag == 1:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)


# Fixed version:
#! python3
# card_game.py

n = int(input())
turns = [input() for i in range(n)]

taro, hanako = 0, 0
for turn in turns:
    t, h = turn.split(' ')
    min_len = len(t) if len(t) <= len(h) else len(h)

    win_flag = 0 # -1: taro, 1: hanako, 0: draw
    for i in range(min_len):
        if ord(t[i]) < ord(h[i]):
            win_flag = 1
            break
        elif ord(h[i]) < ord(t[i]):
            win_flag = -1
            break

    if win_flag == 0:
        if len(t) < len(h):
            win_flag = 1
        elif len(h) < len(t):
            win_flag = -1

    if win_flag == -1:
        taro += 3
    elif win_flag == 1:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)

# Buggy version:
# AOJ ITP1_9_C

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    SCORE_taro = 0
    SCORE_hanako = 0
    n = int(input())
    for i in range(n):
        words = input()
        if words[0] > words[1]: SCORE_taro += 3
        elif words[0] < words[1]: SCORE_hanako += 3
        else:
            SCORE_taro += 1; SCORE_hanako += 1
    print(str(SCORE_taro) + " " + str(SCORE_hanako))

if __name__ == "__main__":
    main()


# Fixed version:
# AOJ ITP1_9_C

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    SCORE_taro = 0
    SCORE_hanako = 0
    n = int(input())
    for i in range(n):
        words = input().split()
        if words[0] > words[1]: SCORE_taro += 3
        elif words[0] < words[1]: SCORE_hanako += 3
        else:
            SCORE_taro += 1; SCORE_hanako += 1
    print(str(SCORE_taro) + " " + str(SCORE_hanako))

if __name__ == "__main__":
    main()

# Buggy version:
a = 0
b = 0
num = int(input())
for i in range(num):
    s1,s2 = input().split()
    s1 = s1.lower()
    s2 = s2.lower()
    if s1 < s2:
        b += 3
    elif s1 > s2:
        a += 3
    else:
        a += 1
        b += 1
print(a,' ',b)



# Fixed version:
a = 0
b = 0
num = int(input())
for i in range(num):
    s1,s2 = input().split()
    s1 = s1.lower()
    s2 = s2.lower()
    if s1 < s2:
        b += 3
    elif s1 > s2:
        a += 3
    else:
        a += 1
        b += 1
print(a,b)

# Buggy version:
taro = 0
hana = 0
n = int(input())
for _ in range(n):
    taro_s, hana_s = map(str, input().split())
    if taro_s < hana_s:
        taro += 3
    elif hana_s < taro_s:
        hana += 3
    else:
        taro += 1
        hana += 1
print(taro, hana)



# Fixed version:
taro = 0
hana = 0
n = int(input())
for _ in range(n):
    taro_s, hana_s = map(str, input().split())
    if taro_s > hana_s:
        taro += 3
    elif hana_s > taro_s:
        hana += 3
    else:
        taro += 1
        hana += 1
print(taro, hana)

# Buggy version:
n = int(input())
T = H = 0
for x in range(n):
    t, h = input().split()
    tl = list(t)
    hl = list(h)
    z = min([int(len(tl)),int(len(hl))])
    for k in range(z):
        if ord(tl[k]) > ord(hl[k]):
            T += 3
            break
        elif ord(tl[k]) == ord(hl[k]):
            pass
        else:
            H += 3
            break
    else:
        if len(hl) == len(tl):
            T += 1
            H += 1
        elif z == len(tl):
            H += 3
        else:
            T += 3
    print(f"{str(T)} {str(H)}")
print(f"{str(T)} {str(H)}")





# Fixed version:
n = int(input())
T = H = 0
for x in range(n):
    t, h = input().split()
    tl = list(t)
    hl = list(h)
    z = min([int(len(tl)),int(len(hl))])
    for k in range(z):
        if ord(tl[k]) > ord(hl[k]):
            T += 3
            break
        elif ord(tl[k]) == ord(hl[k]):
            pass
        else:
            H += 3
            break
    else:
        if len(hl) == len(tl):
            T += 1
            H += 1
        elif z == len(tl):
            H += 3
        else:
            T += 3
print(f"{str(T)} {str(H)}")

# Buggy version:
n = int(input())
a = 0
b = 0
for i in range(n):
	A,B = map(str,input().split())
	if A>B:
		a += 3
	elif B>A:
		b += 3
	else:
		a += 1
		b += 1
print('%d %d'.(a,b))


# Fixed version:
n=int(input())
a=0
b=0
for i in range(n):
    A,B=map(str,input().split())
    if A>B:
        a+=3
    elif A==B:
        a+=1
        b+=1
    else:
        b+=3
print(a,b)

# Buggy version:
n = input()
for i in range(n):
	taro,hanako = raw_input().split()
	taro_score = 0
	hanako_score = 0
	if taro > hanako :
		taro_score += 3
	elif taro == hanako :
		taro_score += 1
		hanako_score += 1
	else :
		hanako_score += 3
	print '%d %d' %(taro_score,hanako_score)

# Fixed version:
n = int(input())

taro_score = 0
hanako_score = 0

for i in range(n):
    taro,hanako = input().split()

    if taro>hanako:
        taro_score +=3
    elif taro<hanako:
        hanako_score += 3
    else:
        taro_score += 1
        hanako_score += 1
print("%d %d" % (taro_score,hanako_score))

# Buggy version:

Taro = 0
Hanako = 0

n = int(input())

for i in range(n):
    T,H = map(str, input().split())
    if T > H:
        Taro += 3
    elif T = H:
        Taro += 1
        Hanako += 1
    else:
        Hanako += 3

print(Taro, Hanako)



# Fixed version:
n = int(input())
Taro = 0
Hanako = 0
for i in range(n):
    T, H = map(str,input().split())
    if T > H:
        Taro += 3
    elif H > T:
        Hanako += 3
    else:
        Taro += 1
        Hanako += 1
print(Taro, Hanako)

# Buggy version:
n = int(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)

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

# Buggy version:
N=int(input())
x=0
y=0
for i in range(N):
    a,b=input().split()
    if a<b:
        y+=3
    elif a==b:
        x+=1
        y+=1
    else:
        x+=3
print(x,y)


# Fixed version:
N = int(input())
x = 0
y = 0
for i in range(N):
    a,b = input().split()
    if a<b:
        y+=3
    elif a==b:
        x+=1
        y+=1
    else:
        x+=3
print(x,y)

# Buggy version:
t,h=0,0
n=int(input())
for i in range(n):
    a,b=input().split()
    if a > b:
        h+=3
    elif a < b:
        t+=3
    else:
         t+=1
         h+=1
print(t, h)

# Fixed version:
n = int(input())
t, h = 0, 0
for i in range(n):
  a, b = input().split()
  if a<b:
    h += 3
  elif a>b:
    t += 3
  else:
    h += 1
    t += 1
print(t, h)