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

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 H_card > T_card:
        H_point += 3
    else:
        T_point += 1
        H_point += 1
print(T_point, H_point)

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

Solution (Python):
n = int(input())
taro = 0
hana = 0
for _ in range(n):
	taro_c, hana_c = input().split()
	if taro_c > hana_c:
		taro += 3
	elif hana_c > taro_c:
		hana += 3
	else:
		taro += 1
		hana += 1

print(taro, hana)

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

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):
Pt = 0
Ph = 0

n = int(input())

for i in range(n):
    I = input().split()
    Taro = I[0]
    Hanako = I[1]
    if Taro > Hanako:
        Pt += 3
    if Taro < Hanako:
        Ph += 3
    if Taro == Hanako:
        Pt += 1
        Ph += 1

print(str(Pt) + ' ' + str(Ph))

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

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

print(*score)

Solution (Python):
times = int(input())
taro_s = 0
hanako_s = 0
for i in range(times):
    taro_a, hanako_a = input().split()
    if taro_a > hanako_a:
        taro_s += 3
    elif taro_a < hanako_a:
        hanako_s += 3
    else:
        hanako_s += 1
        taro_s += 1
print(taro_s, hanako_s)

Solution (Python):
class Reader:
    def __init__(self):
        self.l = 0
        self.r = 0

    def __call__(self, s):
        l, r = s.split()
        if l > r:
            self.l += 3
        elif l < r:
            self.r += 3
        else:
            self.l += 1
            self.r += 1

    def __str__(self):
        return "{} {}".format(self.l, self.r)

reader = Reader()

n = int(input())
for _ in range(n):
    reader(input())
print(reader)

Solution (Python):
t,h=0,0
n=int(input())
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(t, h)

Solution (Python):
num_of_match=int(input())
poi_of_1=0
poi_of_2=0
for i in range(num_of_match):
    car_1,car_2=input().split()
    if car_1==car_2:
        poi_of_1+=1
        poi_of_2+=1
    elif car_1>car_2:
        poi_of_1+=3
    elif car_1<car_2:
        poi_of_2+=3
print(poi_of_1,poi_of_2)

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

print('%d %d' %(taro, hanako))

Solution (Python):


n = int(raw_input())
scores = [0,0]
for i in range(n):
    tarou, hanako = raw_input().split()
    if tarou > hanako:
        scores[0] += 3
    elif tarou < hanako:
        scores[1] += 3
    else:
        scores[0] += 1
        scores[1] += 1

print scores[0], scores[1]

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

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

Solution (Python):
N = int(input())
taro_p = hana_p = 0
for n in range(N):
  tw,hw = input().split()
  if tw == hw:
    taro_p += 1
    hana_p += 1
  elif tw < hw:
    hana_p += 3
  else :
    taro_p += 3

print(taro_p,hana_p)

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

taro = 0
hanako = 0

for i in range(num):
	cards = raw_input().split()
	if cards[0] < cards[1]:
		hanako += 3
	elif cards[0] == cards[1]:
		taro += 1
		hanako += 1
	else:
		taro += 3

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

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

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

tp = 0
hp = 0

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

print('%d %d' % (tp, hp) )

Solution (Python):
def main():

    match_count = int(input())
    matches = [input().split() for i in range(match_count)]
    
    taro_result = [3 if match[0] > match[1] else 1 if match[0] == match[1] else 0 for match in matches]
    print('%d %d' % (sum(taro_result), sum(3 if item == 0 else 1 if item == 1 else 0 for item in taro_result)) )


main()

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

print('%d %d' % (tc, hc))

Solution (Python):

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

Solution (Python):


def main():

    inputLine = int(input())

    taro = hanako = 0

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

    print('%d %d' % (taro, hanako))



if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
p_taro = 0
p_hanako = 0
for i in range(n):
	taro, hanako = map(str, input().split())
	cards = tuple(sorted((taro, hanako)))
	

	if taro == hanako:
		p_taro += 1
		p_hanako += 1
	else:
		if cards == (taro, hanako):
			p_hanako += 3
			
		else:
			p_taro += 3
			

print(p_taro, p_hanako)

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

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

Solution (Python):
def main():
    n = int(input())
    point_t = 0
    point_h = 0
    for _ in range(n):
        t, h = input().split()
        if t == h:
            point_t += 1
            point_h += 1
        elif t > h:
            point_t += 3
        else:
            point_h += 3

    print(point_t, point_h)

if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
a = []
for i in range(n):
    a.append(list(map(str, input().split())))   
    
taro = []
hanako = []
for i in range(len(a)):
    if a[i][0] > a[i][1]:
        taro.append(3)
    elif a[i][0] == a[i][1]:
        taro.append(1)
        hanako.append(1)
    else:
        hanako.append(3)
print(sum(taro),sum(hanako))

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

print(n1, n2)

Solution (Python):
count = int(input())
Tpoint = 0
Hpoint = 0
for i in range(count):
    Twrite,Hwrite = map(str,input().split())
    if Twrite == Hwrite:
        Tpoint = Tpoint + 1
        Hpoint = Hpoint + 1
    elif Twrite > Hwrite:
        Tpoint = Tpoint + 3
    else:
        Hpoint = Hpoint + 3
print('{0} {1}'.format(Tpoint,Hpoint))

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

tscore, hscore = 0, 0
for i in range(num):
    ts, hs = input().split()
    if ts > hs:
        tscore += 3
    elif ts < hs:
        hscore += 3
    else:
        tscore += 1
        hscore += 1
print(tscore, hscore)

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

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

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 = input()
taro_cnt = 0
hanako_cnt = 0
taro = ["" for i in range(n)]
hanako = ["" for i in range(n)]
for i in range(n):
    split = raw_input().split()
    taro[i] = split[0]
    hanako[i] = split[1]
for i in range(n):
    if taro[i] > hanako[i]:
        taro_cnt += 3
    elif taro[i] < hanako[i]:
        hanako_cnt += 3
    else:
        taro_cnt += 1
        hanako_cnt += 1
else:
    print taro_cnt,hanako_cnt

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

Solution (Python):
def cardgame(animal1, animal2, taro, hanako):
    if animal1==animal2:
        return [taro+1, hanako+1]
    anim_list = sorted([animal1, animal2])
    if anim_list[0]==animal1:
        return [taro, hanako+3]
    else:
        return [taro+3, hanako]

n = int(input())
taro, hanako = 0, 0
for i in range(n):
    data = input().split()
    result = cardgame(data[0], data[1], taro, hanako)
    taro, hanako = result[0], result[1]
print(taro, end=" ")
print(hanako)

Solution (Python):
n = int(input())
x = 0
y = 0
for _ 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):
A, B = 0, 0
num = int(input())
for i in range(num):
    a, b = input().split()
    if a < b:
        B += 3
    elif a > b:
        A += 3
    else:
        A += 1
        B += 1
print(A, B)

Solution (Python):
n = int(input())
t_point = h_point = 0
for i in range(n):
    t_card,h_card = [x for x in input().split( )]
    if t_card > h_card:
        t_point += 3
    elif t_card < h_card:
        h_point += 3
    else:
        t_point += 1
        h_point += 1
print(t_point,h_point)

Solution (Python):
n = int(input())
T_point = H_point = 0
for _ in range(n):
    T_card,H_card = [x for x in input().split()]
    if T_card > H_card:
        T_point += 3
    elif T_card < H_card:
        H_point += 3
    else:
        T_point += 1
        H_point += 1
print(T_point,H_point)

Solution (Python):



import sys

n = int(sys.stdin.readline())
t_score = h_score = 0

for i in range(n):
    t_card, h_card = sys.stdin.readline().split()
    if t_card > h_card:
        t_score += 3
    elif t_card < h_card:
        h_score += 3
    else:
        t_score += 1
        h_score += 1

print(t_score, h_score)

Solution (Python):
t=0
h=0
n=input()
for _ in range (n):
	s = raw_input().split()
	if s[0] > s[1]:
		t+=3
	elif s[0] < s[1]:
		h+=3
	else:
		t+=1
		h+=1
print str(t) + " " + str(h)

Solution (Python):
def card_game(pairs):
    points = [0, 0]
    for pair in pairs:
        if (pair[0] > pair[1]):
            points[0] += 3
        elif (pair[0] < pair[1]):
            points[1] += 3
        else:
            points[0] += 1
            points[1] += 1

    return points

if __name__ == '__main__':
    n = int(input())
    pairs = []
    for _ in range(n):
        pairs.append(input().split())

    points = card_game(pairs)
    print(' '.join(map(str, points)))

Solution (Python):
n = int(input())
score = [0,0]
for _ in range(n):
    tc, hc = input().split()
    if tc == hc:
        score[0] += 1
        score[1] += 1
    elif tc > hc:
        score[0] += 3
    else:
        score[1] += 3
print(*score)

Solution (Python):
tp = hp = 0
for i in range(int(input())):
    taro, hana = map(list, input().split())
    short = min(len(taro), len(hana))
    result = 0
    for k in range(short):
        if ord(taro[k]) != ord(hana[k]):
            result = ord(taro[k]) - ord(hana[k])
            break
    if not result:
        if len(taro) < len(hana):
            result = -1
        elif len(taro) > len(hana):
            result = 1
    if result > 0:
        tp += 3
    elif result < 0:
        hp += 3
    else:
        tp += 1
        hp += 1
print(tp, hp)

Solution (Python):
n = int(input())
i = 0
p0 = 0
p1 = 0
while i < n:
    s = list(map(str, input().split(' ')))
    if s[0] > s[1]:
        p0 += 3
    elif s[0] < s[1]:
        p1 += 3
    else:
        p0 += 1
        p1 += 1
    i += 1
print(str(p0) + ' ' + str(p1))

Solution (Python):
def scores(card1, card2):
    """returns scores of a card game.

    >>> scores('cat', 'dog')
    (0, 3)
    >>> scores('fish', 'fish')
    (1, 1)
    >>> scores('tiger', 'lion')
    (3, 0)
    """
    if card1 == card2:
        return (1, 1)
    elif card1 > card2:
        return (3, 0)
    else:
        return (0, 3)


def run():
    c = int(input())
    taro, hanako = 0, 0

    for i in range(c):
        pt, ph = scores(*(input().split()))
        taro += pt
        hanako += ph

    print(taro, hanako)


if __name__ == '__main__':
    run()

Solution (Python):
n = int(input())
t_score = 0
h_score = 0

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

print(t_score, h_score)

Solution (Python):


p = [0,0]
n = int(input())
for i in range(n):
    c1 = input().split(" ")
    c2 = sorted(c1)

    if c1[0] == c1[1]:
        p[0] += 1
        p[1] += 1

    elif c1[0] == c2[0]:
        p[1] += 3
    else:
        p[0] += 3

print(str(p[0]) + " " + str(p[1]))

Solution (Python):
t = 0; h = 0
for _ in range(int(input())):
  a, b = map(str, input().split())
  if a == b:
    t += 1
    h += 1
    continue
  l = sorted([a, b])
  if [a, b] == l:
    h += 3
  else:
    t += 3
print("{0} {1}".format(t, h))

Solution (Python):
t = h = 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):
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

taro = 0
hanako = 0
for i in range(1,len(l)):
    if l[i][1] > l[i][0]:
        hanako += 3
    elif l[i][0] > l[i][1]:
        taro += 3
    else:
        hanako += 1
        taro += 1

print(taro,hanako)

Solution (Python):
n = int(input())
t_count = 0
h_count = 0
for i in range(n):
    t_animal,h_animal = map(str,input().split())
    if t_animal < h_animal:
        h_count+=3
    elif t_animal > h_animal:
        t_count+=3
    else:
        t_count+=1
        h_count+=1
print("{} {}".format(t_count,h_count))

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

for _ in range(n):
    idiom_list = list(input().split(' '))
    sort_list = sorted(idiom_list)
    if idiom_list[0] == idiom_list[1]:
        taro += 1
        hana += 1
    else:
        if idiom_list == sort_list:
            hana += 3
        else:
            taro += 3

print('{a} {b}'.format(a=taro, b=hana))

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())
t = 0
h = 0
for n in range(N):
    w = input().split()
    if w[0] == w[1]:
        t += 1
        h += 1
    elif w[0] > w[1]:
        t += 3
    else:
        h += 3
print(t,h)

Solution (Python):
N=int(input())
Taro=0
Hanako=0
for i in range(N):
    T,H=map(str,input().split())
    if T<H:
        Hanako+=3
    elif H<T:
        Taro+=3
    else:
        Hanako+=1
        Taro+=1
print(Taro,Hanako)

Solution (Python):


n = int(input())
t_point, h_point = 0, 0

for i in range(n):
    t_card,  h_card  = map(str, input().split())

    if t_card == h_card:
        t_point += 1
        h_point += 1
    elif t_card > h_card:
        t_point += 3
    elif t_card < h_card:
        h_point += 3

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

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

Solution (Python):



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

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

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

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

Solution (Python):

n = int(input())
taro = 0
hanako = 0

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

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

Solution (Python):
import string
from itertools import zip_longest

turn = int(input())
dic = {s: i for i, s in enumerate(string.ascii_lowercase)}
t_s, h_s = 0, 0

for _ in range(turn):
    t, h = input().split()
    if t == h:
        t_s += 1
        h_s += 1
    for t_c, h_c in zip_longest(t, h, fillvalue='a'):
        if dic[t_c] > dic[h_c]:
            t_s += 3
            break
        elif dic[t_c] < dic[h_c]:
            h_s += 3
            break

print(t_s, h_s)

Solution (Python):
n = int(input())
T_p, H_p = 0, 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):


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

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

Solution (Python):
def judge():
    if t > h:
        point["t"] += 3
    elif t < h:
        point["h"] += 3
    else:
        point["t"] += 1; point["h"] += 1

n = int(input())
point = {"t": 0, "h": 0}
for i in range(n):
    t, h = input().split()
    judge()
print(point["t"], point["h"])

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

t = 0
h = 0
for i in range(n):
	card1, card2 = map(str, input().split())
	if card1 > card2:
		t += 3
	elif card1 < card2:
		h += 3
	else:
		t += 1
		h += 1

print(str(t) + ' ' + str(h))

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

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

Solution (Python):
s = [0, 0, 0]
loop = int(raw_input())
for i in range(loop):
    w1, w2 = raw_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]

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

Solution (Python):


cardAmount = int(input())

taro = 0
hanako = 0
for i in range(cardAmount):
    cards = input().rstrip().split()
    sortedCards = sorted(cards)
    if cards[0] == cards[1]:
        taro += 1
        hanako += 1
    elif cards == sortedCards:
        hanako += 3
    else:
        taro += 3
print(taro, hanako)

Solution (Python):
n = int(input())
tscore = 0
hscore = 0
for i in range(n):
    wlist = []
    t,h = map(str, input().split())
    wlist.append(t)
    wlist.append(h)
    order = sorted(wlist, key = str.lower)
    if (t.lower() == h.lower()):
        tscore += 1
        hscore += 1
    elif (order[1] == t):
        tscore += 3
    elif (order[1] ==h ):
        hscore += 3
print(tscore, hscore)

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

Solution (Python):
n = int(raw_input())
T = 0
H = 0

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

print("%d %d" % (T, H))

Solution (Python):
import sys

def judge(word1, word2):
    lena = len(word1)
    lenb = len(word2)
    for i in range(min(lena,lenb)):
        if word1[i] > word2[i]: return 1
        elif word1[i] < word2[i]: return 2
    if lena > lenb: return 1
    elif lena < lenb: return 2
    else: return 0

p = 0
s = [0, 0, 0]
for line in sys.stdin:
    ls = line.strip('\n')
    if p ==0:
        loop = int(ls)
        p = 1
    elif p == 1:
        if loop <= 0: break
        w1, w2 = ls.split()
        tmp = judge(w1, w2)
        if tmp == 0:
            s[1] += 1
            s[2] += 1
        else:
            s[tmp] += 3
        loop -= 1
print s[1], s[2]

Solution (Python):
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(raw_input())
for i in range(loop):
    w = raw_input().split()
    tmp = judge(*w)
    if tmp == 0:
        s[1] += 1
        s[2] += 1
    else:
        s[tmp] += 3
print s[1], s[2]

Solution (Python):
s = [0, 0, 0]
loop = int(raw_input())
for i in range(loop):
    w1, w2 = raw_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]

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

Solution (Python):
n=int(raw_input())
p=[0,0]
for i in range(n):
        c=[0 for i in range(100)]
        c=map(list,raw_input().split())
        m=0
        while 1:
                try:
                        if c[0]==c[1]:
                                p[0]+=1
                                p[1]+=1
                                break
                        elif c[0][m]<c[1][m]:
                                p[1]+=3
                                break
                        elif c[1][m]<c[0][m]:
                                p[0]+=3
                                break
                        m+=1
                except IndexError:
                        if len(c[0])<len(c[1]):
                                p[1]+=3
                                break
                        if len(c[1])<len(c[0]):
                                p[0]+=3
                                break
print p[0], p[1]

Solution (Python):
from __future__ import division, print_function
from sys import stdin
n = int(stdin.readline())
result = [0, 0]
for _ in range(n):
    taro, hanako = stdin.readline().split()
    if taro > hanako:
        result[0] += 3
    elif taro < hanako:
        result[1] += 3
    else:
        result[0] += 1
        result[1] += 1
print(*result)

Solution (Python):
taro,hanako = 0,0
w=[]
n = int(raw_input())
for i in xrange(n):
    w.append(map(str, raw_input().split()))
for j in xrange(n):
    if w[j][0]>w[j][1]:
        taro+=3
    elif w[j][0]<w[j][1]:
        hanako+=3
    else:
        taro+=1
        hanako+=1


print taro,hanako

Solution (Python):
n = input()
s = [0, 0]
while n>0:
	n -= 1
	l = raw_input().split()
	if l[0] == l[1]:
		s[0] += 1
		s[1] += 1
	elif sorted(l) == l:
		s[1] += 3
	else:
		s[0] += 3
print s[0], s[1]

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

Solution (Python):
score = [0, 0]

n = int(raw_input())
for i in range(n):
    t, h = raw_input().split()
    if t < h:
        score[1] += 3
    elif t > h:
        score[0] += 3
    else:
        score[0] += 1
        score[1] += 1
print score[0], score[1]

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

Solution (Python):
n=int(input())
T=0
H=0
for i in range(n):
    card_t,card_h=input().split()
    if card_t==card_h:
        T+=1
        H+=1
    else:
        if card_h>card_t:
            H+=3
        else:
            T+=3
print(T,H)

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

Solution (Python):
n=int(input())
score=[0,0,0]
for _ in range(n):
    tc,hc=map(str,input().split())
    if tc==hc:
        score[1]+=1
        score[-1]+=1
        continue
    i=0
    ml=min(len(tc),len(hc)) 
    while tc[i]==hc[i]:
        i+=1
        if i>=ml:
            tc+="0"
            hc+="0"
            break
    r=ord(tc[i])-ord(hc[i])
    r=r//abs(r)
    score[r]+=3

print("{} {}".format(score[1],score[-1]))

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

t=0
h=0

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

Solution (Python):
n=int(input())
t_won=0
h_won=0
for _ in range(n):
	t_wd,h_wd=input().split()
	if t_wd>h_wd: t_won+=1
	elif t_wd<h_wd: h_won+=1
print(t_won*3+(n-t_won-h_won),h_won*3+(n-t_won-h_won))

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

print(T,H)

Solution (Python):
n = int(input())
Taro_ten = 0
Hanako_ten = 0
for i in range(n) :
    a, b = list(input().split())
    Taro = list(a)
    Hanako = list(b)
    length = min(len(Taro), len(Hanako))
    for i in range(length) :
        if ord(Taro[i]) > ord(Hanako[i]) :
            Taro_ten += 3
            break
        elif ord(Taro[i]) < ord(Hanako[i]) :
            Hanako_ten += 3
            break
        if i == length -1 :
            if len(Taro) > length :
                Taro_ten += 3
            elif len(Hanako) > length :
                Hanako_ten += 3
            else :
                Taro_ten += 1
                Hanako_ten += 1
print(Taro_ten, Hanako_ten)

Solution (Python):
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
    elif a<b:
        B+=3
print(A,B)

Solution (Python):

x=int(input())
list=[]
c=0
d=0
for i in range(x):
    a,b=input().split()
    
    if a<b:
        d+=3
    elif a>b:
        c+=3
    else:
        c+=1
        d+=1
print(c,d)

Solution (Python):
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 :
        b+= 3
    else :
        a+= 1
        b+= 1
        
print(a,b)

Solution (Python):
t=0
h=0
for i in range(int(input())):
    A,B=list(input().split())
    if A>B:
        t+=3
    if A<B:
        h+=3
    if A==B:
        t+=1
        h+=1
print(t,h)

Solution (Python):
x = int(input())
T = 0
H = 0
for i in range(x):
    a,b = map(str,input().split())
    if a < b:
        H+=3
    elif a == b:
        T+=1
        H+=1
    else:
        T+=3

print(T,H)

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

Solution (Python):
from string import ascii_lowercase as asc
n = int(input())
card = []
point = [0,0]
for i in range(n):
	card.append(list(map(str,input().split())))
for k in range(len(card)):
	if card[k][0] == card[k][1]:
		point[0] += 1
		point[1] += 1
	elif card[k][0] == card[k][1][:len(card[k][0])]:
		point[1] += 3
	elif card[k][1] == card[k][0][:len(card[k][1])]:
		point[0] += 3
	else:
		s = 0
		while True:
			if card[k][0][s] == card[k][1][s]:
				s += 1
			else:
				break
		for kk in asc:
			if card[k][0][s] == kk:
				point[1] += 3
				break
			elif card[k][1][s] == kk:
				point[0] += 3
				break
print(" ".join(list(map(str,point))))