Problem:
Card Game Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card.
  The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each. Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game. Input In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card. Constraints  n ≤ 1000  The length of the string ≤ 100  Output Print the final scores of Taro and Hanako respectively. Put a single space character between them. Sample Input 3
cat dog
fish fish
lion tiger Sample Output 1 7

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
n = int(input())
 
T_s = 0
H_s = 0
 
for i in range(n):
    animals = input().split()
    T_a = animals[0]
    H_a = animals[1]
    if T_a < H_a:
        H_s += 3
    elif T_a > H_a:
        T_s += 3
    else:
        T_s += 1
        H_s += 1
 
print(T_s, H_s)

Solution (Python):
n = int(input())
  
T_s = 0
H_s = 0
  
for i in range(n):
    animals = input().split()
    T_a = animals[0]
    H_a = animals[1]
    if T_a < H_a:
        H_s += 3
    elif T_a > H_a:
        T_s += 3
    else:
        T_s += 1
        H_s += 1
  
print(T_s, H_s)

Solution (Python):
n=int(input())
T,H=0,0
for i in range(n):
    t_card,h_card=input().split()
    if t_card>h_card:
        T+=3
    elif t_card<h_card:
        H+=3
    else:
        T+=1
        H+=1
print(str(T)+" "+str(H))

Solution (Python):
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))

Solution (Python):
taro = 0
hanako = 0
n = int(input())

for i in range(n):
    t, h = input().split()
    if t == h:
        taro += 1
        hanako += 1
    elif t > h:
        taro += 3
    else:
        hanako += 3

print(taro, hanako)

Solution (Python):
t = h = 0
for _ in range(int(input())):
    taro, hanako = input().split()
    if taro > hanako:
        t += 3
    elif hanako > taro:
        h += 3
    elif taro == hanako:
        t += 1
        h += 1
print(t, h)

Solution (Python):

n = input()
x = y = 0
for _ in xrange(n):
 a, b = raw_input().split()
 if a==b:
  x += 1
  y += 1
 elif a>b:
  x += 3
 else:
  y += 3
print x, y

Solution (Python):
tarou = 0
hanako = 0
n = int(input())
for i in range(n):
    str1, str2 = input().split()
    if str1 > str2:
        tarou += 3
    elif str1 < str2:
        hanako += 3
    else:
        tarou += 1
        hanako += 1
print("{0} {1}".format(tarou, hanako))

Solution (Python):
n = int(raw_input())
score_taro, score_hana = 0, 0

for i in range(n):
    taro, hana = raw_input().split(" ")

    if taro > hana:
        score_taro += 3
    elif taro < hana:
        score_hana += 3
    else:
        score_taro += 1
        score_hana += 1

print(str(score_taro) + " " + str(score_hana))

Solution (Python):
t = 0
h = 0

for i in range(int(input())):
    cards = input().split()
    if cards[0] > cards[1]:
        t += 3
    elif cards[0] == cards[1]:
        t += 1
        h += 1
    else:
        h += 3
        
print(str(t) + " " + str(h))

Solution (Python):
n = int(raw_input())

point = [0, 0]
for i in range(n):
    word = map(str, raw_input().split())
    if word[0] == word[1]:
        point[0] += 1
        point[1] += 1
    elif len(word[0]) >= len(word[1]):
        for j in range(len(word[1])):
            if word[0][j] == word[1][j]:
                if j == len(word[1])-1:
                    point[0] += 3
                continue
            elif word[0][j] > word[1][j]:
                point[0] += 3
                break
            else:
                point[1] += 3
                break
    else:
        for j in range(len(word[0])):
            if word[0][j] == word[1][j]:
                if j == len(word[0])-1:
                    point[1] += 3
                continue
            elif word[0][j] > word[1][j]:
                point[0] += 3
                break
            else:
                point[1] += 3
                break
print "%d %d" % (point[0], point[1])

Solution (Python):
s = int(input())
t = h = 0
for _ in range(s):
    tc, hc = input().split()
    if tc == hc:
        t += 1
        h += 1
    elif tc > hc :
        t += 3
    else:
        h += 3
print(t, h)

Solution (Python):
n = int(input())
tarou = 0
hanako = 0
for i in range(n):
    w1, w2 = input().split()
    if w1 == w2:
        tarou += 1
        hanako += 1
    elif w1 > w2:
        tarou += 3
    else:
        hanako += 3

print(tarou, hanako)

Solution (Python):
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))

Solution (Python):
n = int(input())
Taro = 0
Hanako = 0

for i in range(n):
    t,h = input().split()
    if t == h:
        Hanako += 1
        Taro += 1
    elif t> h:
        Taro += 3
    else:
         Hanako += 3
print("{} {}".format(Taro,Hanako))

Solution (Python):
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))

Solution (Python):

N=int(input())

taro_pt=0
hanako_pt=0
for i in range(0,N):
    taro_str,hanako_str=map(str,input().split())
    if taro_str>hanako_str:
        taro_pt=taro_pt+3
    elif taro_str<hanako_str:
        hanako_pt=hanako_pt+3
    else:
        taro_pt=taro_pt+1
        hanako_pt=hanako_pt+1

print(str(taro_pt)+" "+str(hanako_pt))

Solution (Python):
round = int(raw_input())
score = {"taro":0, "hanako":0}
counter = 0
while counter < round:
    [taro,hanako] = raw_input().split()
    if taro < hanako:
        score["hanako"] += 3
    elif taro > hanako:
        score["taro"] += 3
    else:
        score["taro"] += 1
        score["hanako"] += 1
    counter += 1

print score["taro"], score["hanako"]

Solution (Python):
if __name__ == '__main__':
    
    game_count = int(input())
    deck_taro = [''] * game_count
    deck_hanako = [''] * game_count
    for i in range(game_count):
        data = [x for x in input().split(' ')]
        deck_taro[i] = data[0]
        deck_hanako[i] = data[1]

    
    point_taro = 0
    point_hanako = 0
    for i in range(game_count):
        if deck_taro[i] < deck_hanako[i]:
            point_hanako += 3
        elif deck_taro[i] > deck_hanako[i]:
            point_taro += 3
        else:
            point_hanako += 1
            point_taro += 1

    
    print('{0} {1}'.format(point_taro, point_hanako))

Solution (Python):
n = int(input())
taro = 0
hana = 0
for c in range(0,n):
    word = input().split(' ')
    taro_w, hana_w = word[0], word[1]
    word.sort()
    if word[0] == word[1]:
        taro += 1
        hana += 1
    elif taro_w == word[0]:
        hana += 3
    else:
        taro += 3
print("%d %d" % (taro, hana))

Solution (Python):
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)

Solution (Python):
taro = hanako = 0                    
for _ in range(int(input())):        
  t, h = input().split()             
  if t == h:                         
    taro += 1                        
    hanako += 1                      
  elif t > h:                        
    taro += 3                        
  else:                              
    hanako += 3                      
print("{} {}".format(taro, hanako))

Solution (Python):
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)

Solution (Python):
n=int(input())
A=0
B=0
for i in range(n):
	a,b=input().split()
	if a>b:
		A+=3
	elif a==b:
		A+=1
		B+=1
	else:
		B+=3
print(A,B)

Solution (Python):
t,h=0,0
for _ in range(int(input())):
    a,b=input().split()
    if a == b:
        t+=1
        h+=1
    elif a < b:
        h+=3
    else:
        t+=3
print(t,h)

Solution (Python):
i = int(input())

taro = 0
hanako = 0
for i in range(i):
    a, b = input().split()

    if a > b:
        taro += 3
    elif a < b:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print(taro, hanako)

Solution (Python):
n = int(input())

t, h = 0, 0

for i in range(n):
    s1, s2 = input().split()
    if s1 > s2:
        t += 3
    elif s1 < s2:
        h += 3
    else:
        t += 1
        h += 1

print(t, h)

Solution (Python):

n = int(input())
t_p = 0
h_p = 0

for _ in range(n):
    t_w, h_w = input().split()
    if t_w > h_w:
        t_p += 3
    elif h_w > t_w:
        h_p += 3
    else:
        t_p += 1
        h_p += 1
        
print(t_p, h_p)

Solution (Python):
n=eval(input())
taro=[]
hanako=[]
for i in range(n):
    x,y=input().split()
    taro.append(x)
    hanako.append(y)
T=0
H=0
for i in range(n):
    if taro[i]<hanako[i]:
        H=H+3
    elif taro[i]>hanako[i]:
        T=T+3
    else:
        H=H+1
        T=T+1
print(T,H)

Solution (Python):
count = int(input())
t, h = 0, 0
for line in range(count):
    s1,s2 = input().split()
    if s1 > s2:
        t += 3
    elif s1 < s2:
        h += 3
    else:
        t += 1
        h += 1
print(t, h)

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

Solution (Python):
score = {"taro":0, "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(score["taro"], score["hanako"])

Solution (Python):


N = int(input())
taro = 0
hanako = 0
for i in range(N):
	strs = input().split()
	if strs[0] > strs[1]:
		taro += 3
	elif strs[0] < strs[1]:
		hanako += 3
	else:
		taro+=1
		hanako+=1

print(str(taro) + " " + str(hanako))

Solution (Python):
n=int(input())
s=[0,0]
for i in range(n):
    t, h = input().strip().split()
    if t>h:
        s[0] += 3
    elif t<h:
        s[1] += 3
    else:
        s[0] += 1
        s[1] += 1
print(*s)

Solution (Python):
n = int(input())

card = ['' for i in range(n)]
score1 = 0
score2 = 0


def win(score):
    score += 3
    return score


def draw(score):
    score += 1
    return score

for i in range(n):
    card[i] = [j for j in input().split()]

for i in range(n):
    if card[i][0] == card[i][1]:
        score1 = draw(score1)
        score2 = draw(score2)
    else:
        if card[i][0] > card[i][1]:
            score1 = win(score1)
        else:
            score2 = win(score2)

print(score1,score2)

Solution (Python):
n = int(raw_input())
taro = 0
hanako = 0

for i in range(n):
    S = (raw_input()).split(" ")
    if (S[0] > S[1]):
        taro += 3
    elif (S[0] == S[1]):
        hanako += 1
        taro += 1
    else:
        hanako += 3

print str(taro) + " " + str(hanako)

Solution (Python):
n = int(input())
TARO = HANAKO = 0
for i in range(n):
    taro, hanako = input().split()
    if taro == hanako:
        TARO += 1
        HANAKO += 1
    elif taro > hanako:
        TARO += 3
    elif taro < hanako:
        HANAKO += 3
print(TARO, HANAKO)

Solution (Python):
h=t=0
for _ in range(int(input())):
    a,b=input().split()
    if a>b:t+=3
    elif a<b:h+=3
    else:t+=1;h+=1
print(t,h)

Solution (Python):
n = int(input())
x,y = 0,0
for i in range(n):
    d = input().split()
    if d[0] == d[1]:
        x += 1
        y += 1
    else:
        a = list(d[0])
        b = list(d[1])
        for i in range(min(len(a),len(b))):
            if int(a[i],36) > int(b[i],36):
                x += 3
                break
            elif int(a[i],36) < int(b[i],36):
                y += 3
                break
            if i == min(len(a),len(b))-1:
                if len(a) < len(b):
                    y += 3
                else:
                    x += 3

print(x,y)

Solution (Python):
import sys
lines = [line.split() for line in sys.stdin]
T = H = 0
n = int(lines[0][0])
for w1,w2 in lines[1:]:
    if w1 > w2:
        T += 3
    elif w1 < w2:
        H += 3
    else:
        T += 1
        H += 1
print (str(T) + " " + str(H))

Solution (Python):
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)

Solution (Python):
import sys


fin = sys.stdin

n = int(fin.readline())

taros_score = 0
hanakos_score = 0
winner_points = 3
draw_points = 1

for i in range(n):
	s0, s1 = fin.readline().split()

	if s0 > s1:
		taros_score += winner_points
	elif s0 < s1:
		hanakos_score += winner_points
	else:
		taros_score += draw_points
		hanakos_score += draw_points

print(taros_score, hanakos_score)

Solution (Python):



import sys


def main():
    n = int(sys.stdin.readline().strip('\n'))
    taro_score = 0
    hanako_score = 0

    for turn in range(n):
        animals = [animal for animal in
                   sys.stdin.readline().strip('\n').split(' ')]
        if animals[0] == animals[1]:
            taro_score += 1
            hanako_score += 1
        elif max(animals[0], animals[1]) == animals[0]:
            taro_score += 3
        elif max(animals[0], animals[1]) == animals[1]:
            hanako_score += 3

    print('%d %d' % (taro_score, hanako_score))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

TP = 0
HP = 0

for i in range(N):
	TC, HC = input().split()
	if TC > HC:
		TP += 3
	elif TC < HC:
		HP += 3
	else:
		TP += 1
		HP += 1

print(TP,HP)

Solution (Python):
n = int(input())
t = 0
h = 0
for i in range(n):
    taro,hana = input().split()
    if taro == hana:
        t += 1
        h += 1
    else:
        m = list((taro,hana))
        m.sort()
        if m == list((taro,hana)):
            h += 3
        else:
            t += 3
print("{} {}".format(t,h))

Solution (Python):
n = int(raw_input())
t = 0
h = 0
for i in range(n):
    line = raw_input().split()
    if line[0] == line[1]:
        t += 1
        h += 1
    elif line[0] > line[1]:
        t += 3
    else:
        h += 3
print '{0} {1}'.format(t,h)

Solution (Python):
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)

Solution (Python):
game_time = int(input().strip())
game_cnt = 0
p_Taro = 0
p_Hanako = 0

while game_cnt < game_time:
    game_cnt = game_cnt + 1
    Taro, Hanako = input().split(" ")
    
    if Taro > Hanako:
        p_Taro = p_Taro + 3
    elif Taro < Hanako:
        p_Hanako = p_Hanako + 3
    else:
        p_Taro = p_Taro + 1
        p_Hanako = p_Hanako + 1
    
print(p_Taro, p_Hanako)

Solution (Python):
n = int(input())
p_t = 0
p_h = 0
for i in range(n):
    c_t,c_h = map(str,input().split())
    if c_t > c_h:
        p_t += 3
    elif c_t < c_h:
        p_h += 3
    else:
        p_t += 1
        p_h += 1
print(p_t,p_h)

Solution (Python):
round = int(input())
points =[0, 0]
for r in range(round):
    taro, hanako = input().split(" ")
    if taro == hanako:
        points[0] += 1
        points[1] += 1
    elif taro > hanako:
        points[0] += 3
    elif taro < hanako:
        points[1] += 3

print(*points)

Solution (Python):
n = int(input())
a = b = 0
for _ in range(n):
    s1, s2 = [i for i in input().split()]
    if s1 == s2:
        a += 1
        b += 1
    elif s1 > s2: a += 3
    else: b += 3
print(a,b)

Solution (Python):
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
					
					break
				else:
					p_t += 3
					
					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)

Solution (Python):
n = int(input())
a = [[i for i in input().split()] for i in range(n)]
taroup = 0
hanakop = 0
for i in range(n):
    array =[]
    array.append(a[i][0])
    array.append(a[i][1])
    array.sort()
    if array[1] == a[i][0] and  array[1] != a[i][1]:
        taroup += 3
    elif array[1] == a[i][1] and  array[1] != a[i][0]:
        hanakop += 3
    elif array[0] == array[1]:
        taroup += 1
        hanakop += 1
print(str(taroup)+" "+str(hanakop))

Solution (Python):
taro, hanako = (0, 0)
for i in range(int(input())):
    t, h = input().strip().split()
    if t > h:
        taro += 3
    elif t < h:
        hanako += 3
    else:
        taro += 1
        hanako +=  1

print(taro, hanako)

Solution (Python):
poi = [0,0]
for mak in range(int(input())) :
    tem = input().split()
    if tem[0] == tem[1] :
        poi[0] += 1
        poi[1] += 1
    else :
        che = sorted(tem)

        if tem[0] != che[0] : poi[0] += 3
        else                : poi[1] += 3

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

Solution (Python):
n = int(input())
ans = [0, 0]
for i in range(n):
    [t, h] = input().split()
    sort = [t, h]
    sort.sort()
    if t==h:
        ans[0] += 1
        ans[1] += 1
    elif [t, h]==sort:
        ans[1] += 3
    else:
        ans[0] += 3

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

Solution (Python):
taro_score = 0
hanako_score = 0

for i in range(int(input())):
    taro,hanako = input().split()
    if taro < hanako:
        hanako_score += 3
    elif taro > hanako:
        taro_score += 3
    else:
        taro_score += 1
        hanako_score += 1
        
print(str(taro_score),str(hanako_score))

Solution (Python):


import sys
import os


N = int(input())
score0 = 0
score1 = 0
for i in range(N):
    word0, word1 = input().split()
    if word0 < word1:
        score1 += 3
    elif word0 > word1:
        score0 += 3
    else:
        score0 += 1
        score1 += 1
print(score0, score1)

Solution (Python):
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)

Solution (Python):
n = int(input())
s_taro,s_hanako = 0,0

for trial in range(n):
    taro,hanako = list(map(str, input().split()))
    if taro > hanako:
        s_taro += 3
    elif taro < hanako:
        s_hanako += 3
    else:
        s_taro += 1
        s_hanako += 1

print(s_taro, s_hanako)

Solution (Python):
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))

Solution (Python):



def compute_card_game_score():
    players = ("player_A", "player_B")
    (score, cards) = ("score", "cards")
    
    
    game_log = {player : {score : 0, cards : []} for player in players}
    try:
        tmp = input()
        while(True):
            cards_pair = input().rstrip().split()
            [ game_log[player][cards].append(cards_pair[i]) for i,player in enumerate(players) ]
    except EOFError:
        pass
    except:
        return inputError()
    
    
    for pairs in zip(game_log[players[0]][cards], game_log[players[1]][cards]):
        if pairs[0] == pairs[1] :
            for player in players:
                game_log[player][score] += 1
        elif pairs[0] > pairs[1] :
            game_log[players[0]][score] += 3
        elif pairs[0] < pairs[1] :
            game_log[players[1]][score] += 3
    
    print( " ".join([ str(game_log[player][score]) for player in players ]) )
    
def inputError():
    print("input Error")
    return -1



if __name__ == "__main__" :
    compute_card_game_score()

Solution (Python):
n = int( input() )
t_won = 0
h_won = 0

for _ in range(n):
    t, h = input().split(" ")
    if t < h:
        h_won += 1
    if t > h:
        t_won += 1
print(t_won*3 + (n - t_won - h_won), h_won*3 + (n - t_won - h_won))

Solution (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))

Solution (Python):
n=int(input())
T=0
H=0
for i in range(n):
    [a,b]=input().split(" ")
    if(a>b):
        T+=3
    elif(a<b):
        H+=3
    else:
        T+=1
        H+=1
print(str(T)+" "+str(H))

Solution (Python):
n = int(input())
Taro, Hanako = 0, 0
for _ in range(n):
    a, b = input().split()
    li = sorted(list((a, b)))
    if a == b:
        Taro += 1
        Hanako += 1
    elif a == li[1]:
        Taro += 3
    else:
        Hanako += 3
print("{} {}".format(Taro,Hanako))

Solution (Python):
def main():
    n = int(input())

    points = [0, 0]

    for i in range(n):
        t, h = input().split(' ')

        points = map(lambda x, y: x+y, points, judge(t, h))

    print("{0[0]} {0[1]}".format(list(points)))

def judge(t, h):
    if t < h:
        return (0, 3)
    elif t > h:
        return (3, 0)

    return (1, 1)

if __name__ == '__main__': main()

Solution (Python):
n = int(input())
ts = 0
hs = 0
for i in range(n):
 taro, hanako = input().split()
 if taro > hanako:
  ts += 3
 elif taro < hanako:
  hs += 3
 else:
  ts += 1
  hs += 1
print(str(ts) + " " + str(hs))

Solution (Python):


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))))

Solution (Python):
n = int(input())
x, y = 0, 0
for i in range(n):
    a, b = input().split()
    if a > b:
        x += 3
    elif a < b:
        y += 3
    else:
        x += 1
        y += 1
print(x, y)

Solution (Python):
point_t = 0
point_h = 0
n = int(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)

Solution (Python):
n = int(input())
taro = 0
hanako = 0
for i in range(n):
    s = input().split(" ")
    if s[0] > s[1]:
        taro += 3
    elif s[0] < s[1]:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print("{0} {1}".format(taro, hanako))

Solution (Python):
n = int(input())
taro = 0
hanako = 0

for i in range(n):
	animals = input().split()
	taro_animal = animals[0]
	hanako_animal = animals[1]
	if taro_animal > hanako_animal:
		taro += 3
	elif taro_animal < hanako_animal:
		hanako +=3
	else:
		taro += 1
		hanako += 1

print(taro, hanako)

Solution (Python):
n=input()
t_p=0
h_p=0
for i in range(int(n)):
    t,h=input().split()
    a=sorted([t,h])
    if t == h:
        t_p+=1
        h_p+=1
    elif t  == a[1]:
        t_p+=3
    else:
        h_p+=3
print(t_p, h_p)

Solution (Python):
n = int(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)

Solution (Python):
t=int(input())
taro=0
hanako=0
for i in range(t):
    S=input().split()

    if S[0]==S[1]:
        taro+=1
        hanako+=1
    elif S[0]>S[1]:
        taro+=3
    else:
        hanako+=3
print(taro,hanako)

Solution (Python):
n = int(input())

a = 0
b = 0

for _ in range(n):
    word_a, word_b = input().split()

    words = [word_a, word_b]
    words.sort()

    if word_a == word_b:
        a += 1
        b += 1
    elif words.index(word_a) == 1:
        a += 3
    else:
        b += 3

print(a, b)

Solution (Python):
n = int(input())
a, b = 0, 0
for i in range(n):
    s1, s2 = input().split()
    if s1 > s2:
        a += 3
    elif s1 == s2:
        a += 1
        b += 1
    else:
        b += 3
print('{0} {1}'.format(a, b))

Solution (Python):


"""
?????????????????£?????????
"""
turns = int(input().strip())
hanako = 0
tarou = 0
for i in range(turns) :
   tcard, hcard = input().strip().split()

   if tcard == hcard :
       hanako += 1
       tarou += 1
   elif tcard > hcard :
       tarou += 3
   else:
       hanako += 3

print("{0} {1}".format(tarou,hanako))

Solution (Python):
n=int(input())
pointx=0
pointy=0
for i in range(n):
    x,y=[j for j in input().split()]
    p=1
    if len(x)<len(y):
        for j in range(len(x)):
            if ord(list(x)[j])>ord(list(y)[j]):
                pointx=pointx+3
                p=0
                break
            elif ord(list(x)[j])<ord(list(y)[j]):
                pointy=pointy+3
                p=0
                break
        if p:
            pointy=pointy+3
    elif len(x)==len(y):
        for j in range(len(x)):
            if ord(list(x)[j])>ord(list(y)[j]):
                pointx=pointx+3
                p=0
                break
            elif ord(list(x)[j])<ord(list(y)[j]):
                pointy=pointy+3
                p=0
                break
        if p:
            pointx=pointx+1
            pointy=pointy+1
    else:
        for j in range(len(y)):
            if ord(list(x)[j])>ord(list(y)[j]):
                pointx=pointx+3
                p=0
                break
            elif ord(list(x)[j])<ord(list(y)[j]):
                pointy=pointy+3
                p=0
                break
        if p:
            pointx=pointx+3
print("{0} {1}".format(pointx,pointy))

Solution (Python):
n = int(input())
taro,hanako = 0,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('{0} {1}'.format(taro,hanako))

Solution (Python):
def main():
    N = int(input())
    Card = tuple(tuple(input().split()) for _ in range(N))

    taro = 0
    hanako = 0
    for c in Card:
        if c[0] > c[1]:
            taro += 3
        elif c[0] < c[1]:
            hanako += 3
        else:
            taro += 1
            hanako += 1

    print(taro, hanako)

main()

Solution (Python):
n = int(input())
L=[]
st=0
sh=0
for i in range(n):
    x,y=input().split()
    L.append([x,y])




for i in L:
    j=sorted(i)
    if i[0] == i[1]:
        st+=1
        sh+=1
    else:
        if i[0] ==j[0]:
            sh += 3
        else:
            st+=3


print (st,sh)

Solution (Python):
n=int(input())

T=0
H=0

for i in range(n):
    t,h=list(input().split())
    if t==h:
        T+=1
        H+=1
    elif t>h:
        T+=3
    elif t<h:
        H+=3
        
print(T,H)

Solution (Python):
n_turn = int(input())
t_point = h_point = 0
for i in range(n_turn):
    t_card, h_card = input().split()
    if t_card > h_card:
        t_point += 3
    elif t_card == h_card:
        t_point += 1
        h_point += 1
    else:
        h_point += 3
print("{} {}".format(t_point, h_point))

Solution (Python):
n = int(input())
a, b = [0, 0]
for i in range(n):
    Taro, Hanako = input().split()
    if Taro > Hanako:
        a += 3
    elif Taro < Hanako:
        b += 3
    else:
        a += 1
        b += 1
print(a, b)

Solution (Python):
n=int(input())
HPOINT=0
TPOINT=0
for _ in range(n):
  HANAKO,TAROU=input().split()
  if HANAKO>TAROU:
    HPOINT += 3
  elif HANAKO<TAROU:
    TPOINT += 3
  elif HANAKO==TAROU:
    HPOINT+=1
    TPOINT+=1
print(HPOINT,TPOINT)

Solution (Python):
tarop = hanakop = 0
for i in range(int(input())):
    taro, hanako = input().split()
    if taro > hanako:
        tarop += 3
    elif taro < hanako:
        hanakop += 3
    else:
        tarop += 1
        hanakop += 1
print(tarop, hanakop)

Solution (Python):
n = int(input())
 
T_s = 0
H_s = 0
 
for i in range(n):
    animals = input().split()
    T_a = animals[0]
    H_a = animals[1]
    if T_a < H_a:
        H_s += 3
    elif T_a > H_a:
        T_s += 3
    else:
        T_s += 1
        H_s += 1
 
print(T_s, H_s)

Solution (Python):
n=int(input())
tp = 0
hp = 0
for _ in range(n):
    taro,hanaco = input().split()
    if taro == hanaco :
        tp +=1
        hp +=1
    elif taro > hanaco :
        tp += 3
    else: hp += 3
print('{} {}'.format(tp,hp))

Solution (Python):
loop = int(raw_input())
taro = []
hanako = []
taro_score = 0
hanako_score = 0
for i in range(loop):
    t, h = raw_input().split()
    taro += [t]
    hanako += [h]

for t, h in zip(taro,hanako):
    if t < h:
        hanako_score += 3
    if t > h:
        taro_score += 3
    if t == h:
        taro_score += 1
        hanako_score += 1
print "%d %d" % (taro_score, hanako_score)

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


taro, hanako = 0, 0
n = int(input())
for _ in range(n):
    s1, s2 = input().split()
    if s1 == s2:
        taro += 1
        hanako += 1
    elif s1 > s2:
        taro += 3
    else:
        hanako += 3

print(taro, hanako)