Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import Counter
N = int(input())
L = []
for n in range(N):
    S = input()
    L.append(S)
Dic = Counter(L)
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max(Dic.values())]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

### FIXED CODE ###

from collections import Counter
N = int(input())
L = [input() for _ in range(N)]
#for n in range(N):
    #S = input()
    #L.append(S)
Dic = Counter(L)
max_value = max(Dic.values())
max_k_list = [i for i, j in Dic.items() if j == max_value]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)
### BUGGY CODE ###

rflag = 0
s = input()
q = int(input())

for i in range(q):
    x = input().split()
    
    if (x[0] == '1'):
        s = s[::-1]
    else:
        if(x[1] == '1'):
            s = x[2] + s
        else:
            s += x[2]
print(s)

### FIXED CODE ###

from collections import deque

revFlag = False

s = deque(input())
q = int(input())

for i in range(q):
    a,b,c, *_ = input().split() + [None, None]
    
    if(a == '1'):
        revFlag = not revFlag
        
    else:
        b = int(b)
        if(revFlag):
            b = (int(b)%2)+1
        
        if(b == 1):
            s.appendleft(c)
        else:
            s.append(c)
            
    #print(_,*s, sep="")

if(revFlag):
    s.reverse()
    
print(*s, sep='')
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
S = S.replace('AC', 'aC')
for i in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r-1].count('a'))

### FIXED CODE ###

#解説より
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])
### BUGGY CODE ###

import collections

n = int(input())
s = list(input() for i in range(n))
c = collections.Counter(s)
p = max(c.values())
t = []

for i in range(len(c)):
    if c.most_common()[i][1] == p:
        t.append(c.most_common()[i][0])
    else:
        break

t.sort()
for i in range(len(t)):
    print(t[i])

### FIXED CODE ###

import collections

n = int(input())
s = list(input() for i in range(n))
s = sorted(s)
c = collections.Counter(s)
p = max(c.values())
s = sorted(list(set(s)))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split(' ')]

A.sort(reverse=True)
max_value = A.pop(0)
diff = [max_value]
ans = 0
for i in A:
    n = diff.pop(0)
    ans = ans + n
    diff = diff + [i, i]

print(ans)

### FIXED CODE ###

import sys
from collections import deque

N = int(sys.stdin.readline())
A = [int(i) for i in sys.stdin.readline().split(' ')]

A.sort(reverse=True)
max_value = A.pop(0)
diff = deque([max_value])
ans = 0
for i in A:
    ans = ans + diff.popleft()
    diff.append(i)
    diff.append(i)

print(ans)
### BUGGY CODE ###


def main():
    t = input()
    if t == "1":
        print(1)
        exit(0)
    li = [int(v) for v in input().split(' ')]
    s_li = sorted(li)
    count = 0
    for v in s_li:
        t_c = s_li.count(v - 1) + s_li.count(v) + s_li.count(v + 1)
        t_c2 = s_li.count(v) + s_li.count(v + 1) + s_li.count(v + 2)

        if t_c > count:
            count = t_c
        if t_c2 > count:
            count = t_c2
        if count > len(s_li):
            break
    print(count)


if __name__ == '__main__':
    main()



### FIXED CODE ###

n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v+1] += 1
    cnt[v+2] += 1
    
print(max(cnt))
### BUGGY CODE ###

import heapq

h = []
N, M = [int(i) for i in input().split()]
for i in input().split():
    heapq.heappush(h, int(i))

for _ in range(M):
    B, C = [int(i) for i in input().split()]
    for j in range(B):
        if h[0] >= C:
            break
        heapq.heappop(h)
        heapq.heappush(h, C)

print(sum(h))



### FIXED CODE ###

import heapq

h = []
h2 = []
N, M = [int(i) for i in input().split()]
count = dict()
count2 = dict()
for i in input().split():
    if not count.get(i):
        count[i] = 0
    count[i] += 1
for k, v in count.items():
    heapq.heappush(h, (int(k), v))

for _ in range(M):
    B, C = [int(i) for i in input().split()]
    if not count2.get(C):
        count2[C] = 0
    count2[C] += B
for k, v in count2.items():
    heapq.heappush(h2, (-k, v))
while len(h2) > 0:
    C, B = heapq.heappop(h2)
    C = -C
    while B > 0:
        if h[0][0] >= C:
            break
        m = h[0][0]
        mc = h[0][1]
        if mc > B:
            heapq.heappush(h, (C, B))
            h[0] = (m, mc - B)
        else:
            heapq.heappop(h)
            heapq.heappush(h, (C, mc))
        B -= mc
print(sum([i[0] * i[1] for i in h]))
### BUGGY CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())
sary = [sorted(stdin.readline().rstrip()) for _ in range(n)]

res = 0
for i in range(n):
    for j in range(i+1, n):
        if sary[i] == sary[j]:
            res += 1

print(res)

### FIXED CODE ###

from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
sary = sorted(["".join(sorted(stdin.readline().rstrip())) for _ in range(n)])

gr = groupby(sary)

res = 0

for k, g in gr:
    num = len(list(g))
    if  num >= 2:
        res += num * (num - 1) // 2

print(res)
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in a:
    b.append(i)
    b = b[::-1]
print(*b)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
b = [0 for _ in range(n)]
i = n-1
j = 0
while True:
    b[j] = a[i]
    if i-2 < 0:
        j += 1
        break
    j += 1
    i -= 2
if n%2==0:
    i = 0
else:
    i = 1
while i < n:
    b[j] = a[i]
    j += 1
    i += 2
        
print(*b)
### BUGGY CODE ###

import sys
import math
import copy

def is_prime(N):
    i = 2
    while i * i <= N:
        if N % i == 0:
            return i
        i += 1
    return N

def main():
    N = int(input())
    if N == 1:
        print(0)
        sys.exit()
    a = is_prime(N)
    if a == N:
        print(1)
        sys.exit()
    else:
        count = 0
        ori_N = copy.copy(N)
        for i in range(2, ori_N):
            if N < i:
                break
            if N % i == 0:
                a = is_prime(i)
                if a == i:
                    count += 1
                    N //= i
                else:
                    now = i
                    while now > a:
                        now /= a
                        if now == a:
                            count += 1
                            N //= i
        print(count)

if __name__ == '__main__':
     main()



### FIXED CODE ###

import sys
import math


def is_prime(N):
    if N == 1:
        return False
    i = 2
    while i * i <= N:
        if N % i == 0:
            return False
        i += 1
    return True

def prime(N):
    prime = []
    is_prime = []  # 全て素数であると初期化
    for i in range(N):
        if i * i > N:
            break
        is_prime.append(True)
    is_prime[0] = is_prime[1] = False # 0,1は素数ではない
    n = len(is_prime)
    for i in range(2, n):
        if is_prime[i]:
            # iは素数である
            prime.append(i)
            for j in range(2 * i, n, i):
                # iの倍数は素数でない
                is_prime[j] = False
    # N以下の素数を表示
    return prime, n

def main():
    N = int(input())
    if N == 1:
        print(0)
    else:
        if is_prime(N):
            print(1)
        else:
            prime_list, n = prime(N)
            used = []
            prime_exponentiation = []
            count = 0
            for i in range(len(prime_list)):
                now = prime_list[i]
                j = 1
                while now ** j <= N:
                    prime_exponentiation.append(now ** j)
                    j += 1
            prime_exponentiation.sort()
            for i in range(len(prime_exponentiation)):
                now = prime_exponentiation[i]
                if N < now:
                    j = 0
                    while not is_prime(N):
                        if N == 1:
                            break
                        while N % prime_list[j] == 0:
                            N //= prime_list[j]
                        j += 1 
                    break
                if N % now == 0:
                    count += 1
                    used.append(now)
                    N //= now
            if N not in used and N != 1:
                count += 1
            print(count)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

# wrong answer
K=int(input())
A=[1,2,3,4,5,6,7,8,9]
for _ in range(K-1):
    n=A.pop(0)
    if n%10!=0: A.append(10*n+(n%10-1))
    A.append(10*n+n%10)
    if n%10!=9: A.append(10*n+(n%10+1))
print(A.pop(0))

### FIXED CODE ###

K=int(input())
A=[1,2,3,4,5,6,7,8,9]
for _ in range(K-1):
    if K <= len(A): break
    K -= len(A)
    B=[]
    A,B=B,A
    for b in B:
        if b%10!=0: A.append(10*b+(b%10-1))
        A.append(10*b+b%10)
        if b%10!=9: A.append(10*b+(b%10+1))
print(A[K-1])
### BUGGY CODE ###

n = int(input())

k = []

for i in range(n):
  s = input()
  if not s in k:
    k.append(s)

print(len(k))

### FIXED CODE ###

n = int(input())

k = []

for i in range(n):
  k.append(input())

print(len(set(k)))
### BUGGY CODE ###

n, k = map(int,input().split())
p = [int(i) for i in input().split()]

psum = [0] * (n - k + 1)
for i in range(n - k + 1):
  psum[i] = sum(p[i:i+k])
res = (max(psum)+k) / 2
print(res)

### FIXED CODE ###

n, k = map(int,input().split())
p = [int(i) for i in input().split()]

psum = [0] * (n - k + 1)
psum[0] = sum(p[0:k])
for i in range(1, n - k + 1):
  psum[i] = psum[i-1] - p[i-1] + p[i + k - 1]
res = (max(psum)+k) / 2
print(res)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

s = input()
K = int(input())

sub = []
for i in range(1,int(len(s))+1):
    for j in range(0,int(len(s))):
        if s[j:j+i] in sub:
            pass
        else:
            sub.append(s[j:j+i])

sub=sorted(sub)
print(sub[K-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-

s = input()
K = int(input())

sub = []
for i in range(1,6):
    for j in range(0,int(len(s))):
        if s[j:j+i] in sub:
            pass
        else:
            sub.append(s[j:j+i])

sub=sorted(sub)
print(sub[K-1])
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))


counter = N  # l != rの場合を以下では考える
for l in range(N):
    r = l - 1
    while r < N-1:
        r += 1
        sum_A = sum(A[l:r+1])
        if r == l:
            xor_A = A[r]
        else:
            xor_A = xor_A ^ A[r]
            if xor_A == sum_A:
                counter += 1



print(counter)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)
### BUGGY CODE ###

import collections
import numpy as np
import sys
import copy

N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]-=1
B=[0]
C=[]
Flag=True
for i in range(0,N*2):
    B.append(A[B[i]])
    if len(B)%2==0:
        for j in range(len(B)//2):
            u=B[-j - 1:]
            v=B[(-j-1)*2:-j-1]
            if u==v:
                C=list(B[-j-1:])
                Flag=False
                num=len(B)-2*len(C)
    if not Flag:
        break
#print(C)
Ans=(K-num)%len(C)
print(C[Ans]+1)

### FIXED CODE ###

import collections
import numpy as np
import sys
import copy

N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]-=1
B=[0]
visited=[0]*N
visited[0]=1
Flag=True
for i in range(0,N*2):
    next=A[B[i]]
    if visited[next]==0:
        B.append(next)
        visited[next]=1
    else:
        C=B[B.index(next):]
        num=B.index(next)
        break
#print(C)
if K>num:
    Ans=(K-num)%len(C)
    print(C[Ans]+1)
else:
    print(B[K]+1)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()

n=int(input())
xs=input()
xj=xs.count("1")

x=int(xs,2)
xip=x%(xj+1)
if xj!=1:
    xim=x%(xj-1)

i1=1<<n
for i in range(n-1,-1,-1):
    i1=i1>>1
#    xi=x^i1
#    if xi==0:
#        print(0)
#        continue
    if xs[n-1-i]=="0":
        pxi=xj+1
        xi=(xip+i1%pxi)%pxi
    elif xj==1:
        print(0)
        continue
    else:
        pxi=xj-1
        xi=(xim-i1%pxi)%pxi
    xi=xi%pxi
    if xi==0:
        print(1)
        continue
    icnt=1
    while xi>0:
#        print("i",i,"xi",xi,"icnt",icnt)
        icnt+=1
        xi=xi%(bin(xi).count("1"))
    print(icnt)



### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

n=int(input())
xs=input()
xj=xs.count("1")

x=int(xs,2)
xip=x%(xj+1)
if xj!=1:
    xim=x%(xj-1)

for i in range(n-1,-1,-1):
    if xs[n-1-i]=="0":
        pxi=xj+1
        i2=pow(2,i,pxi)
        xi=(xip+i2)%pxi
    elif xj==1:
        print(0)
        continue
    else:
        pxi=xj-1
        i2=pow(2,i,pxi)
        xi=(xim-i2)%pxi
    xi=xi%pxi
    if xi==0:
        print(1)
        continue
    icnt=1
    while xi>0:
#        print("i",i,"xi",xi,"icnt",icnt)
        icnt+=1
        xi=xi%(bin(xi).count("1"))
    print(icnt)
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split()))
S = 0
for i in range(N - 1):
  T = 0
  for j in range(N - i - 1):
    # print(As[i], As[i + 1 + j])
    T += As[i + 1 + j]
  T = T % 1000000007
  S += As[i] * T
print(S % 1000000007)

### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
S = 0
T = 0
for i in range(N):
  S += As[i]
  T += (As[i] * As[i]) % 1000000007
# print(S)
# print(T)
A = S*S % 1000000007
B = T % 1000000007
X = (A - B) % 1000000007

print((X * int((1000000007 + 1)/2)) % 1000000007)
### BUGGY CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))
lst=[1]*(n-k+1)
for i in range(n-k+1):
  if i==0:
    temp=1
    for j in range(k):
      if A[j]!=1:
        temp*=A[j]
    lst[i]=temp
  else:
    lst[i]=lst[i-1]*A[i+k-1]//A[i-1]
    print("Yes" if lst[i]>lst[i-1] else "No")

### FIXED CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(1, n-k+1):
    print("Yes" if A[i+k-1]>A[i-1] else "No")
### BUGGY CODE ###

s = input()
q = int(input())
q_list = [input().split() for i in range(q)]

flag = False
for q_num in q_list:
    if int(q_num[0]) == 1:
        if flag == False:
            flag = True
        else:
            flag = False
    
    if int(q_num[0]) == 2:
        if int(q_num[1]) == 1 and flag == False or int(q_num[1]) == 2 and flag == True:
            s = q_num[2] + s
        else:
            s = s + q_num[2]

if flag:
    print(s[::-1])
else:
    print(s)

### FIXED CODE ###

s = input()
q = int(input())
q_list = [input().split() for i in range(q)]

flag = False
add_after = ""
add_before = ""
for q_num in q_list:
    if int(q_num[0]) == 1:
        if flag == False:
            flag = True
        else:
            flag = False
    
    else:
        if int(q_num[1]) == 1 and flag == False or int(q_num[1]) == 2 and flag == True:
            add_before = q_num[2] + add_before
        else:
            add_after = add_after + q_num[2]

result = add_before + s + add_after
if flag:
    print(result[::-1])
else:
    print(result)
### BUGGY CODE ###

from collections import Counter

n = int(input())
s = str(input())
s_count = Counter(list(s))

ans = 1
count = 0

for i, j in s_count.items():
    count += 1
    ans *= j

if count < 3:
    ans = 0
    

for i in range(n):
    k = 1

    while i + 2 * k < n:
        l = [s[i], s[i+k], s[i+2*k]]
        if l.count('R') == 1 and l.count('G') == 1 and l.count('B') == 1:
            ans -= 1
        
        k += 1
    
print(ans)

### FIXED CODE ###

n = int(input())
s = str(input())

count = [0] * 3

for i in range(n):
    if s[i] == 'R':
        count[0] += 1
    if s[i] == 'G':
        count[1] += 1
    if s[i] == 'B':
        count[2] += 1

ans = count[0] * count[1] * count[2]

for i in range(n):
    k = 1
    while i + 2 * k < n:
        l = []
        l.append(s[i])
        l.append(s[i+k])
        l.append(s[i+2*k])
        if l.count('R') == 1 and l.count('G') == 1 and l.count('B') == 1:
            ans -= 1
        
        k += 1

print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split()]
c = N-1
A.sort()
while c > 0:
    num = A[0]^A[c]
    pre_num = A[c]
    B = [A[0],A[c],num]
    while len(B) < N:
        box = num
        num = num^pre_num
        pre_num = box
        B.append(num)
        if pre_num not in A:
            break
    B.sort()
    if A == B:
        break
    c -= 1
if c > 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
c = N-1
A.sort()
num = A[0]^A[c]
pre_num = A[c]
B = [A[0],A[c],num]
while len(B) < N:
    box = num
    num = num^pre_num
    pre_num = box
    B.append(num)
B.sort()
if A == B:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
List=list(map(lambda x:int(x)/2,map(int, set(input().split()))))

def main():
    LCM=1

    for i in List:
        LCM*=i//gcd(LCM,i)

    for i in List:
        if LCM/i%2==0:
            print(0)
            exit()

    print(int(M//(LCM*2)+M%(LCM*2)//LCM))


if __name__ == '__main__':
    main()


### FIXED CODE ###

from fractions import gcd
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
List=list(map(lambda x:int(x)//2,map(int, set(input().split()))))

def main():
    LCM=1

    for i in List:
        LCM*=i//gcd(LCM,i)

    for i in List:
        if LCM//i%2==0:
            print(0)
            exit()

    print(int(M//(LCM*2)+M%(LCM*2)//LCM))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import deque

def main():
    N, M, *L = map(int, open(0).read().split())

    E = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(L[:2 * M])] * 2):
        E[a].append(b)
        E[b].append(a)

    colors = [0] * (N + 1)
    visited = [False] * (N + 1)

    for v, d, c in reversed(tuple(zip(*[iter(L[2 * M + 1:])] * 3))):
        Q = deque([(d, v)])
        while Q:
            cnt, v = Q.popleft()
            if colors[v] == 0:
                colors[v] = c
            visited[v] = cnt
            if cnt > 0:
                Q.extend((cnt - 1, u) for u in E[v] if visited[u] < cnt)

    for c in colors[1:]:
        print(c)

if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque

N, M, *L = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(L[:2 * M])] * 2):
    E[a].append(b)
    E[b].append(a)

colors = [0] * (N + 1)
visited = [-1] * (N + 1)

for v, d, c in reversed(tuple(zip(*[iter(L[2 * M + 1:])] * 3))):
    Q = deque([(d, v)])
    while Q:
        cnt, v = Q.popleft()
        if visited[v] >= cnt:
            continue
        if colors[v] == 0:
            colors[v] = c
        visited[v] = cnt
        if cnt > 0:
            Q.extend((cnt - 1, u) for u in E[v])

for c in colors[1:]:
    print(c)
### BUGGY CODE ###

"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
import collections
import sys

BIGINT = int(1e9) + 7

def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

S = input().strip()

slots = [0] * 13
slots[0] = 1

for p, c in enumerate(reversed(S)):
    xx = pow(10, p, 13)
    new_slots = [0] * 13
    if c == "?":
        for i in range(10):
            for k in range(13):
                idx = (i * xx + k) % 13
                new_slots[idx] = (new_slots[idx] + slots[k]) % BIGINT
    else:
        n = int(c)
        for k in range(13):
            new_slots[(n * xx + k) % 13] = slots[k]
    slots = new_slots

print(slots[5])

### FIXED CODE ###

"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
import collections
import sys

BIGINT = int(1e9) + 7

def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

S = input().strip()

slots = [0] * 13
slots[0] = 1

for p, c in enumerate(reversed(S)):
    xx = pow(10, p, 13)
    new_slots = [0] * 13
    if c == "?":
        for i in range(10):
            for k in range(13):
                idx = (i * xx + k) % 13
                new_slots[idx] = (new_slots[idx] + slots[k]) % BIGINT
    else:
        n = int(c)
        for k in range(13):
            new_slots[(n * xx + k) % 13] = slots[k]
    slots = new_slots

print(slots[5])
### BUGGY CODE ###

k, n = map(int, input().split())
a = list(map(int, input().split()))

mindistance = 10000000

for i in range(1, n+1):
    if i == 1:
        distance = k - (a[0] + (k - a[-1]))
        if distance < mindistance:
            mindistance = distance
        a.append(a[0])
        a.pop(0)
    else:
        distance = k - (a[0] - a[-1])
        if distance < mindistance:
            mindistance = distance
        a.append(a[0])
        a.pop(0)

print(mindistance)

### FIXED CODE ###

k, n = map(int, input().split())
a = list(map(int, input().split()))

a.append(a[0] + k)

distance = []

for i in range(len(a) - 1):
    distance.append(a[i+1] - a[i])

mindistance = 0
for j in distance:
    mindistance += j

print(mindistance - max(distance))
### BUGGY CODE ###

def main():
    N = int(input())
    X = int(input(), 2)

    def popcount(num):
        return bin(num).count("1")
    popc_X = popcount(X)
    pop_table = {i: [popcount(i), 0, 0] for i in range(1, N+1)}
    
    
    def f(x, factor):
        temp = x
        count = 0
        visited = []
        while temp > 0:
            if temp > N:
                # print(temp, popc_X)
                temp = temp % (popc_X + factor)
                count += 1
                # print(temp)
                continue
            if pop_table[temp][1] == 0:
                pop_table[temp][1] = count
            else:
                if pop_table[temp][2]:
                    count += pop_table[temp][1]
                    break
                # count_ans = pop_table[temp][1]
            if pop_table[temp][2] == 0:
                visited.append(temp)
            temp = temp % pop_table[temp][0]
            count += 1

        for v in visited:
            pop_table[v][1] = count - pop_table[v][1]
            pop_table[v][2] = 1
        return count
    
    ans = [0]*N
    for i in range(0, N):
        xi = X ^ (1 << i)
        # print(xi, "xi")
        if xi & (1<<i):
            factor = 1
        else:
            factor = -1
        ans[N-i-1] = f(xi, factor)
    for a in ans:
        print(a)
main()

### FIXED CODE ###

N=int(input())
X=input()
num_X = int(X, base=2)
pop_x = X.count("1")
if pop_x <= 1:
    mod0 = pop_x + 1
    res0 = num_X % mod0
else:
    mod1 = pop_x - 1
    mod0 = pop_x + 1
    res1 = num_X % (mod1)
    res0 = num_X % (mod0)

# pops = [0]*(N+20)
for i in range(N):
    tmp = 0
    if X[i] == "0":
        # +
        tmp = (res0 + pow(2, N-i-1, mod0))%mod0
    else:
        if pop_x == 1:
            print(0)
            continue
        tmp = (res1 - pow(2, N-i-1, mod1))%mod1
    
    if tmp == 0:
        print(1)
        continue
    cnt = 1
    while tmp != 0:
        pop = bin(tmp).count("1")
        tmp %= pop
        cnt += 1
    print(cnt)
### BUGGY CODE ###

import sys
from collections import defaultdict

n, m = map(int, input().split())

wa=defaultdict(lambda: 0)
ac=set()

for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in set(ac):
    continue

  if s == "AC":
    ac.add(p)
  else:
    wa[p] += 1

print(len(ac), sum(wa[i] for i in ac))

### FIXED CODE ###

import sys
from collections import defaultdict

n, m = map(int, input().split())

wa=defaultdict(lambda: 0)
already=set()
ac = 0
for line in sys.stdin:
  p, s = line.split()
  p = int(p)
  if p in already:
    continue

  if s == "AC":
    ac+=1
    already.add(p)
  else:
    wa[p] += 1

print(ac, sum(wa[i] for i in already))