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())
d = 0
e = 0
for i in range(n):
    a,b = map(str,input().split())
    if a < b:
        e += 3
    elif a == b:
        d += 1
        e += 1
    else:
        d += 3
print(d,e)

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

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

ts = 0
hs = 0
for i in range(n):
    c = list(input().split())
    if c[0] > c[1]:
        ts += 3
    elif c[0] < c[1]:
        hs += 3
    else:
        ts += 1
        hs += 1

print(ts, hs)

Solution (Python):
n = int(input())
x = y = 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):
n = int(input())
A = 0
B = 0
for i in range(n):
    animals = list(input().split())
    if animals[0] == animals[1]:
        A += 1
        B += 1
    else:
        A_sorted = sorted(animals)
        if animals[0] == A_sorted[1]:
            A +=3
        else:
            B += 3
print(A, B)

Solution (Python):
taro=0
hanako=0
time=int(input())
for i in range(time):
    lst=input().split()
    if lst[0]==lst[1]:
        taro+=1
        hanako+=1
    
    
    else:
        sort_lst=sorted(lst)
        if lst[0]==sort_lst[1]:
            taro+=3
        elif lst[1]==sort_lst[1]:
            hanako+=3
print(taro,hanako)

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

Solution (Python):
n = int(input())
a, b = 0, 0
for i in range(n):
    c = input().split()
    if c[0] == c[1]:
        a += 1
        b += 1
    else:
        pc = c[0]
        sc = sorted(c)
        if pc == sc[0]:
            b += 3
        else:
            a += 3
print(a, b)

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

ap = 0
bp = 0
for _ in range(n):
    a,b = map(str,input().split())
    if a == b:
        ap += 1
        bp += 1
    elif a > b:
        ap += 3
    else:
        bp += 3
print(ap,bp)

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

hanako_score, taro_score = 0, 0

for i in range(n):
    card_list = [x for x in input().split()]
    sorted_card_list = sorted(card_list)
    
    if card_list[0] == card_list[1]:
        hanako_score += 1
        taro_score += 1
    
    elif card_list[0] == sorted_card_list[0]:
        hanako_score += 3
    
    else:
        taro_score += 3
        
print('{} {}'.format(taro_score, hanako_score))

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

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

t_score = h_score=0

for i in range(n):
    taro, hanako = input().split()
    if taro==hanako:
        t_score+=1
        h_score+=1
    elif taro < hanako:
        h_score+=3
    else:
        t_score+=3

print("%d %d" %(t_score,h_score))

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

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

Solution (Python):
TP = 0
HP = 0
n = int(input())
for _ in range(n):
    t,p = input().split()
    if t > p:
        TP += 3
    elif t < p:
        HP += 3
    else:
        TP += 1
        HP += 1
print(TP,HP)

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

print("{} {}".format(taro, hanako))

Solution (Python):
import sys
import itertools
import math



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
a = 0
b = 0
for _ in range(N):
    L = readline().decode('utf8').split()
    if L[0] == L[1]:
        a += 1
        b += 1
    elif L[0] > L[1]:
        a += 3
    else:
        b += 3

print(a, b)

Solution (Python):
t = int(input())
score = [0, 0]
for i in range(t):
    pair = input().split(" ")
    if pair[0] > pair[1]:
        score[0] += 3
    elif pair[0] < pair[1]:
        score[1] += 3
    else:
        score[0] += 1
        score[1] += 1
print(" ".join(map(lambda x: str(x), score)))

Solution (Python):
n = int(input())
A, B = 0, 0

for _ in range(n):
    s1, s2 = input().split()
    if s1 < s2:
        B += 3
    elif s1 > s2:
        A += 3
    else:
        A += 1
        B += 1

print(A, B)

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

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

taro = 0
hana = 0

for i in range(n) :
    taro_c, hana_c = input().split()
    if taro_c > hana_c :
        taro += 3
    elif taro_c == hana_c :
        taro += 1
        hana += 1
    elif taro_c < hana_c :
        hana += 3

print(taro, hana)

Solution (Python):
n = int(input())
p = 0
q = 0
for i in range(n):
    x, y = map(str, input().split())
    if x > y:
        p += 3
    elif y > x:
        q += 3
    else:
        p += 1
        q += 1
print(p, q)

Solution (Python):
n = int(input())
x, y = 0, 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):
N = int(input())
l = [input().split() for _ in range(N)]

a = 0
b = 0
for i in range(N):
    if l[i][0] > l[i][1]:
        a += 3
    elif l[i][0] < l[i][1]:
        b += 3
    else:
        a += 1
        b += 1
print(a,b)

Solution (Python):
n = int(input())
t = 0
h = 0

for i in range(n):
    tc, hc = input().split()

    if tc > hc:
        t += 3
    elif tc < hc:
        h += 3
    else:
        t += 1
        h += 1

print(t, h)

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

points= [0, 0]
for _ in range(n):
    s, t = input().lower().split()
    if s > t:
        points[0] += 3
    elif s < t:
        points[1] += 3
    else:
        points[0] += 1
        points[1] += 1

print(*points)

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

for i in range(N):
    m,n = map(str,input().split())
    if m > n:
        taro += 3
    elif m < n:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print("%d %d"%(taro,hanako))

Solution (Python):
n = int(input())
ans = [0, 0]
for _ in range(n):
    a, b = map(str, input().split())
    if a == b:
        *ans, = map(lambda x: x+1, ans)
        continue

    ans[a < b] += 3

print(*ans)

Solution (Python):
n = int(input())
card = list(list(input().split() for _ in range(n)))
ans = [0, 0]

for i in range(n):
    if card[i][0] < card[i][1]:
        ans[1] += 3
    elif card[i][0] > card[i][1]:
        ans[0] += 3
    else:
        ans[0] += 1
        ans[1] += 1

print(*ans)

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

Solution (Python):
def game(a,b):
    if a>b:
        return 3
    elif a<b:
        return 0
    else:
        return 1

n=int(input())
sum1=0
sum2=0
for i in range(n):
    a,b=input().split()
    sum1+=game(a,b)
    sum2+=game(b,a)
print(sum1,sum2)

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

t = 0
h = 0
for i in range(a):
    x, y = input().split()
    if(x < y):
        t +=3
    elif(y < x):
        h +=3
    else:
        t +=1
        h +=1
print("{0} {1}".format(h, t))

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

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

score_taro = 0
score_hanako = 0

for i in range(n):
    
    a = input().split()
    b = sorted(a)
    
    if a[0] == a[1]:
        score_taro += 1
        score_hanako += 1
        
    elif a[0] == b[0]:
        score_hanako += 3
        
    else:
        score_taro += 3
        
print(score_taro, score_hanako)

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

t_p = 0
h_p = 0

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

print(t_p, h_p)

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 += 1
        Hanako += 1
    else:
        Taro += 3
print(Taro,Hanako)

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

answer = [0, 0]

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

print(*answer)

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

t = 0
h = 0

for _ in range(n):
    w = input().split()

    if w[0] == w[1]:
        t += 1
        h += 1
    else:
        sw = sorted(w)

        if w[0] == sw[0]:
            h += 3
        else:
            t += 3

print(str.format('{} {}', t, h))

Solution (Python):
N = int(input())
taro,hanako = 0,0
for n in range(N):
    taro_str,hanako_str = input().split(' ')
    if taro_str == hanako_str:
        taro += 1
        hanako += 1
    if taro_str > hanako_str:
        taro += 3
    if hanako_str > taro_str:
        hanako += 3
print(taro,hanako)

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

Solution (Python):

challeng_count = int(input())
score = [0] * 2


for i in range(challeng_count):
    check_data = input().split()
    check_data_sort = sorted(check_data)
    if check_data[0] == check_data[1]:
        score[0] += 1
        score[1] += 1
    elif check_data[0] == check_data_sort[0]:
        score[1] += 3
    else:
        score[0] += 3


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

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

Solution (Python):
tpoint = 0
hpoint = 0
num = int(input())
for i in range(num):
    taro,hanako = map(str,input().split())
    A = sorted(list([taro,hanako]))
    if taro == hanako:
        tpoint +=1
        hpoint +=1
    else:
        if A[0]==taro:
            tpoint += 3
        elif A[0]==hanako:
            hpoint +=3
print(str(hpoint)+' '+str(tpoint))

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

print(Asum,Bsum)

Solution (Python):
taro = 0
hanako = 0
n = int(input())
for i in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        taro += 3
    elif cards[0] < cards[1]:
        hanako += 3
    elif cards[0] == cards[1]:
        taro += 1
        hanako += 1
print(str(taro) + ' ' + str(hanako))

Solution (Python):
t_score = 0
h_score = 0

for i in range(int(input())):
  card1, card2 = input().split(' ')

  if card1 < card2:
    h_score += 3
  elif card1 > card2:
    t_score += 3
  else:
    h_score += 1
    t_score += 1

print(t_score, h_score)

Solution (Python):
n = int(input())
t = 0
h = 0
for i in range(n):
    x,y = map(str, input().split())
    if x > y:
        t += 3
    elif x < y:
        h += 3
    else:
        t += 1
        h += 1
print(f"{t} {h}")

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

Solution (Python):
c = int(input())
p1 = 0
p2 = 0
for i in range(c):
    s1,s2 = map(str,input().split())
    if s1 > s2:
        p1 = p1 + 3
    elif s1 < s2:
        p2 = p2 + 3
    else:
        p1 = p1 + 1
        p2 = p2 + 1
print("{0} {1}".format(p1,p2))

Solution (Python):
x = int(input())
ctr_A = 0
ctr_B = 0

for idx in range(x):
    A,B = input().split()
    
    xSw_OK = False
    if len(A) > len(B):
        xLoop = len(A)
    else:
        xLoop = len(B)
    
    for y in range(xLoop):
        if A[y:y+1] == B[y:y+1]:
            True
        elif A[y:y+1] > B[y:y+1]:
            xSw_OK = True
            ctr_A += 3
        else:
            xSw_OK = True
            ctr_B += 3
        if xSw_OK == True:
            break
    if xSw_OK == False:
        ctr_A += 1
        ctr_B += 1

print(ctr_A,ctr_B)

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

taro = 0
hanako = 0
for _ in range(n):
    
    cards = list(input().split())
    win_card = sorted(cards, reverse=True)[0]
    
    if cards[0] == cards[1]:
        taro += 1
        hanako += 1
    elif cards.index(win_card) == 0:
        taro += 3
    elif cards.index(win_card) == 1:
        hanako += 3

print(f"{taro} {hanako}")

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

Solution (Python):

n = int(input())


t_score = 0
h_score = 0


for i in range(n):
    inp = input()
    inp_list = [j for j in inp.split()]
    t, h = inp.split()
    srtd_inp_list = sorted(inp_list)
    if inp_list[0] == inp_list[1]:
        t_score += 1
        h_score += 1
    elif inp_list[0] != srtd_inp_list[0]:
        t_score += 3
    else:
        h_score += 3

print(f"{t_score} {h_score}")

Solution (Python):

def card_game():
    T = 0
    H = 0

    n = int(input())

    for _ in range(n):
        param = input()
        param = param.split(" ")
        c1 = param[0]
        c2 = param[1]

        if c1 > c2 :
            T += 3
        elif c1 < c2:
            H += 3
        else:
            T += 1
            H += 1

    print(str(T) + " " + str(H) )

if __name__ == "__main__":
    card_game()

Solution (Python):
from enum import Enum
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    EVEN = 2

def comp_str(A,B):
    if A > B:
        return Type.win_Taro
    elif A < B:
        return Type.win_Hanako
    else:
        return Type.EVEN

N = int(input())

point_Taro = 0
point_Hanako = 0

for loop in range(N):
    line = str(input()).split()
    ret_type = comp_str(line[0],line[1])
    if ret_type == Type.win_Taro:
        point_Taro += 3
    elif ret_type == Type.win_Hanako:
        point_Hanako += 3
    else:
        point_Taro += 1
        point_Hanako += 1

print("%d %d"%(point_Taro,point_Hanako))

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

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

ans = [0, 0]

for i in range(n):
    cards = input().split()
    if cards[0] > cards[1]:
        ans[0] += 3
    elif cards[0] < cards[1]:
        ans[1] += 3
    else:
        ans[0] += 1
        ans[1] += 1

print(*ans)

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

taro_score = 0
hanako_score = 0

for _ in range(turn_n):
    taro_card, hanako_card = input().split()
    
    if taro_card > hanako_card:
        taro_score += 3
    elif taro_card < hanako_card:
        hanako_score += 3
    else:
        taro_score += 1
        hanako_score += 1
print(taro_score, hanako_score)

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

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

Solution (Python):
times = int(input())
T = 0
H = 0

for t in range(times):
    t,h = input().split()
    if t > h:
        T += 3
    elif t == h:
        T += 1
        H += 1
    else:
        H += 3
        
print("%d %d"%(T,H))

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

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

for i in range(turns):
    t_card, h_card = input().split(" ")
    if t_card > h_card:
        taro += 3
    elif t_card == h_card:
        taro += 1
        hanako += 1
    else:
        hanako += 3
print(taro, hanako)

Solution (Python):
n = int(input())
s1 = 0
s2 = 0
for i in range(n):
    t1, t2 = map(str, input().split())
    if t1 == t2:
        s1+=1
        s2+=1
    elif t1 > t2:
        s1+=3
    else:
        s2+=3
print(s1, s2)

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

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

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

Solution (Python):
score_t = score_h = 0
n = int(input())
for _ in range(n):
    animal_t, animal_h = input().split()
    if animal_t == animal_h:
        score_t += 1
        score_h += 1
    elif animal_t > animal_h:
        score_t += 3
    else:
        score_h += 3

print(score_t, score_h)

Solution (Python):
ts, hs = 0, 0
n, *S = open(0).read().split()
for t, h in zip(*[iter(S)]*2):
    if t < h:
        hs += 3
    elif t > h:
        ts += 3
    else:
        hs += 1
        ts += 1
print(f'{ts} {hs}')

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

print(ts,hs)

Solution (Python):
num_of_games=int(input())
t_point=0
h_point=0
for i in range(num_of_games):
    t,h=input().split()
    if t < h:h_point+=3;
    elif t>h:
        t_point+=3;
    else:
        t_point+=1; h_point+=1
print(t_point, h_point)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    
    n=int(input())
    taro=hanako=0
    for _ in range(n):
        tw,hw=input().split()
        if tw>hw:
            taro+=3
        elif tw==hw:
            taro+=1
            hanako+=1
        else:
            hanako+=3
    print(taro,hanako)

main()

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

a = 0
b = 0
for i in range(N):
    x, y = map(str, input().split())

    if x > y:
        a += 3
    elif x == y:
        a += 1
        b += 1
    else:
        b += 3

print(a, b)

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

l = "abcdefghijklmnopqrstuvwxyz"

taroscore = 0
hanakoscore = 0


for i in range(n):
  card = input().split()
  taro = card[0]
  hanako = card[1]
  tn = len(taro)
  hn = len(hanako)

  if tn > hn :
    tryn = hn

  else:
    tryn = tn

  for o in range(tryn):


    for j in range(26):
      if taro[o] == l[j]:
        taros = j

    for k in range(26):
      if hanako[o] == l[k]:
        hanakos = k

    if taros > hanakos:
      result = "taro"
      break
    elif taros < hanakos:
      result = "hanako"
      break
    else:
      result = "even"

  if result == "taro":
    taroscore += 3

  elif result == "hanako":
    hanakoscore += 3

  else:
    if tn == hn:
      taroscore += 1
      hanakoscore += 1
    elif tn < hn:
      hanakoscore += 3
    else:
      taroscore += 3

print(taroscore, hanakoscore)

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

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

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

print(taro, hanako)

Solution (Python):
n=int(input())
taro=0
hanako=0
for i in range(n):
    w1,w2=input().split()
    o1,o2=0,0
    m=max(len(w1),len(w2))
    for i in range(len(w1)):
        o1+=ord(w1[i])*123**(m-i)
    for i in range(len(w2)):
        o2+=ord(w2[i])*123**(m-i)
    if o1>o2:
        taro+=3
    elif o1<o2:
        hanako+=3
    else:
        taro+=1
        hanako+=1
print(str(taro)+' '+str(hanako))

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

Solution (Python):
n = int(input())
t,h,x = 0,0,0

for i in range(n):
    a,b = input().split()
    if ord(a[0]) < ord(b[0]):
        h += 3
    elif a == b:
        h += 1
        t += 1
    elif ord(a[0]) == ord(b[0]):
        if len(a) >= len(b):
            if b == a[:len(b)]:
                t += 3
            else:
                for i in range(len(b)):
                    if ord(a[i]) == ord(b[i]):
                        pass
                    elif ord(a[i]) < ord(b[i]):
                        h += 3
                        break
                    else:
                        t += 3
                        break
        elif len(a) < len(b):
            if a == b[:len(a)]:
                h += 3
            else:
                for i in range(len(a)):
                    if ord(b[i]) == ord(a[i]):
                        pass
                    elif ord(b[i]) < ord(a[i]):
                        t += 3
                        break
                    else:
                        h += 3
                        break
    else:
        t += 3
print(f"{t} {h}")

Solution (Python):
n = int(input())
t = h = 0

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

Solution (Python):
n = int(input())
t, h = 0, 0

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

print(t, h)

Solution (Python):
import sys
n=int(input())
p1=0
p2=0
for i in range(n):
    x=input().split()
    if x[0]>x[1]:
        p1+=3
    elif x[0]<x[1]:
        p2+=3
    else:
        p1+=1
        p2+=1
print(p1,p2)

Solution (Python):
n = int(input())
scoreT = 0
scoreH = 0
for i in range(0, n):
    words = input().split(" ")
    if words[0] < words[1]:
        scoreH += 3
    elif words[1] < words[0]:
        scoreT += 3
    elif words[0] == words[1]:
        scoreT += 1
        scoreH += 1
print(str(scoreT)+" "+str(scoreH))

Solution (Python):
turn = int(input())
taro, hana = 0, 0
for i in range(turn):
    p1, p2 = input().split()
    if p1 > p2:
        taro += 3
    elif p1 == p2:
        taro += 1
        hana += 1
    else:
        hana += 3
print(taro, hana)

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

Solution (Python):
n = int(input())
t_point = 0
h_point = 0
for i in range(n):
    t, h = map(str, input().split(" "))
    if t < h:
        h_point += 3
    elif t == h:
        t_point += 1
        h_point += 1
    elif t > h:
        t_point +=3
print(t_point, h_point)

Solution (Python):
n=int(input())
tarou=0
hanako=0
cnt=0

while True:
    t,h=input().split()
    a=0
    if t==h:
        tarou+=1
        hanako+=1
        a=1
    if a==0:
        for i in range(min(len(t),len(h))):
            if t[i]>h[i]:
                tarou+=3
                break
            elif t[i]<h[i]:
                hanako+=3
                break
            if i==min(len(t),len(h))-1:
                if len(t)>len(h):
                    tarou+=3
                    break
                else:
                    hanako+=3
                    break
    cnt+=1
    if cnt==n:
        break
print(tarou,hanako)

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

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

Solution (Python):
n = int(input())
a = 0
b = 0
for _ in range(n):
    word = input().split()
    if word[0] == word[1]:
        a += 1
        b += 1
        continue
    word_sort = sorted(word)
    if word == word_sort:
        b += 3
    else:
        a += 3
print(a, b)

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

for i in range(n):
    lines.append(input().split(" "))
    if lines[i][0] > lines[i][1]:
        Taro+=3
    elif lines[i][0] == lines[i][1]:
        Taro+=1
        Hanako+=1
    else:
        Hanako+=3

print(Taro, Hanako)

Solution (Python):
n=int(input())
taro=0
hana=0
for i in range(n):
    a,b=input().split()
    l=[a,b]
    l.sort()
    if a==b:
        taro+=1
        hana+=1
    elif l[0]==a:
        hana+=3
    else:
        taro+=3
print(taro,hana)

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

Solution (Python):
game_count = int(input())
point_p1 = 0
point_p2 = 0

for _ in range(game_count):
    card_p1, card_p2 = input().split()
    
    if card_p1 < card_p2:
        point_p2 += 3
    elif card_p1 > card_p2:
        point_p1 += 3
    else:
        point_p1 += 1
        point_p2 += 1

print(point_p1, point_p2)

Solution (Python):
N = int(input())
Taro_point = 0
Hanako_point = 0
for i in range(N):
    list = input().split()
    if list[0] == list[1]:
        Taro_point += 1
        Hanako_point += 1
    elif list == sorted(list):
        Hanako_point += 3
    else:
        Taro_point += 3
print(Taro_point,Hanako_point)

Solution (Python):
n = int(input())
t_point = 0
h_point = 0

for i in range(n):
    t_card, h_card = input().split()
    
    if t_card== h_card:
        t_point += 1
        h_point += 1
    elif t_card> h_card:
        t_point += 3
    else:
        h_point += 3

print('{} {}'.format(t_point, h_point))

Solution (Python):


from collections import Counter,deque


from sys import stdin,setrecursionlimit


setrecursionlimit(10**6)
input=stdin.readline

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

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

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

Solution (Python):

n = int(input())
matches = []
for i in range(n):
    matches.append(input().split())


point_a = 0
point_b = 0
for match in matches:
    if match[0] > match[1]:
        point_a += 3
    elif match[0] < match[1]:
        point_b += 3
    elif match[0] == match[1]:
        point_a += 1
        point_b += 1

print('{} {}'.format(point_a, point_b))

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

taro = 0
hanako = 0

for _ in range(games):
    taroinput, hanakoinput = input().split()
    if taroinput == hanakoinput:
        taro += 1
        hanako += 1
        continue
    attempts = min(len(taroinput), len(hanakoinput))
    if len(taroinput) > len(hanakoinput):
        isTaroLonger = True
    else:
        isTaroLonger = False
    iter_taro = iter(taroinput)
    iter_hanako = iter(hanakoinput)
    for i in range(attempts):
        next_taro = next(iter_taro)
        next_hanako = next(iter_hanako)
        if next_taro > next_hanako:
            taro += 3
            break
        elif next_hanako > next_taro:
            hanako += 3
            break
    else:
        if isTaroLonger:
            taro += 3
        else:
            hanako += 3

print(taro, hanako)

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

Solution (Python):
n = int(input())
t_tp = 0
h_tp = 0
for i in range(n):
    t_c,h_c = map(str,input().split())

    if t_c == h_c:
        t_tp += 1
        h_tp += 1
    else:
        t_p = 0
        h_p = 0
        for j in range(len(t_c)):
            t_p += ord(t_c[j])
        for k in range(len(h_c)):
            h_p += ord(h_c[k])
        if t_c > h_c:
            t_tp += 3
        else:
            h_tp += 3
            
        
            
print(t_tp,h_tp)

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

print(taro, hanako)

Solution (Python):
taro_score = 0
hanako_score = 0
for _ in range(int(input())):
    taro, hanako = [str(x) for x in input().split()]
    if taro > hanako:
        taro_score += 3
    elif taro == hanako:
        taro_score += 1
        hanako_score += 1
    else:
        hanako_score += 3
print(taro_score, hanako_score)