Harryxun/stf_run huggingface dataset:
def multiple_factors(i, N):
  factors = []
  factors.append(int(1*i))
  for index in range(1, N//i):
    factors.append(int(index*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[-1]-1] =1
    b_add_index.append(str(factors[index]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
M = 0
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))

### FIXED CODE ###

def multiple_factors(i, N):
  factors = []
  for index in range(0, N//i):
    factors.append(int((index+1)*i))
  return factors
  
def assign_ball(factors, blist, ai, b_add_index):
  sum_b = 0
  for index in range(len(factors)-1, 0, -1):
    sum_b += blist[factors[index]-1]
  
  if ai != sum_b%2:
    blist[factors[0]-1] = 1
    b_add_index.append(str(factors[0]))
  return blist, b_add_index

      
N = int(input())
alist = list(map(int, input().split()))
blist = [0 for i in range(N)]
b_add_index = []
for i in range(N-1,-1, -1):
  factors = multiple_factors(i+1, N)
  blist, b_add_index = assign_ball(factors, blist, alist[i], b_add_index)

if sum(blist)%2 != alist[0]:
  print(-1)
else:
  print(len(b_add_index))
  print(" ".join(b_add_index))
imporot math
r=float(input())

print("%0.5f %0.5f" %(r*r*math.pi,2*r*math.pi))


### FIXED CODE ###

import math
r=float(input())

print("%.5f %.5f" %(r*r*math.pi,2*r*math.pi))
i = int(input())
print("ABC"+i)

### FIXED CODE ###

i = int(input())
print("ABC"+str(i))
A, B, K = map(int, input().split())
L = list(range(A, B + 1))
if len(L) <= 2 * K:
    for l in L:
        print(l)
else:
    ans = []
    for i in range(K):
        ans.append(L[i])
        ans.append(L[-i - 1])
    for a in sorted(ans):
        print(a)

### FIXED CODE ###

A, B, K = map(int, input().split())
L = []

for i in range(K):
    if A + i > B - i:
        break
    else:
        L.append(A + i)
        L.append(B - i)

L = set(L)
L = sorted(L)

for l in L:
    print(l)
a=list(input())
b=list(input())
c=list(input())
next=a.pop(0)
while True:
  if next=="a":
    if not a:
      print("A")
      break
    else:
      next=a.pop(0)
  elif next=="b":
    if not b:
      print("B")
      break
    else:
      next=b.pop(0)
  else :
    if not b:
      print("C")
      break
    else:
      next=c.pop(0)
    

### FIXED CODE ###

a=list(input())
b=list(input())
c=list(input())
next=a.pop(0)
while True:
  if next=="a":
    if not a:
      print("A")
      break
    else:
      next=a.pop(0)
  elif next=="b":
    if not b:
      print("B")
      break
    else:
      next=b.pop(0)
  else :
    if not c:
      print("C")
      break
    else:
      next=c.pop(0)
while True:
  stack = []
  for s in raw_input().split():
    if s in ('+', '-', '*', '/'):
      stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
    else:
      stack.append(float(s))
    print '%.6f' % stack.pop()

### FIXED CODE ###

while True:
	try:
		stack = []
		for s in raw_input().split():
			if s in ('+', '-', '*', '/'):
				stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
			else:
				stack.append(float(s))
		print '%.6f' % stack.pop()
	except EOFError:
		break
N = int(input())
a = len(N)
 
if a == 2 and N[1] == 3:
  print('bon')
elif a == 2 and N[1] == 0 or N[1] == 1 or N[1] == 6 or N[1] == 8:
  print('hon')
elif a == 2 and N[1] == 2 or N[1] == 5 or N[1] == 7 or N[1] == 9:
  print('pon')
elif a == 3 and N[2] == 3:
  print('bon')
elif a == 3 and N[2] == 2 or N[2] == 5 or N[2] == 7 or N[2] == 9:
  print('pon')
elif elif a == 3 and N[2] == 0 or N[2] == 1 or N[2] == 6 or N[2] == 8:
  print('hon')
elif a == 1 and N[0] == 3:
  print('bon')
elif a == 1 and N[0] == 0 or N[0] == 1 or N[0] == 6 or N[0] == 8:
  print('hon')
else:
  print('pon')

### FIXED CODE ###

N = input()
 
if N[-1] == '3':
  print('bon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
  print('pon')
else:
  print('hon')
# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
max_value_count = 0
max_value = 0
next_max_value = max_value

for i in range(N):
    in_value = int(input())
    values[i] = in_value

    if in_value == max_value:
        max_value_count = max_value_count + 1
    elif in_value > max_value:
        next_max_value = max_value
        max_value = in_value
        max_value_count = 1
    elif in_value > next_max_value:
        next_max_value = in_value

max_value_count = value_count_map[max_value]

for row in range(N):
    if values[row] == max_value and max_value_count == 1:
        print(next_max_value)
    else:
        print(max_value)


### FIXED CODE ###

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

N = int(input())

values = [0]*N
value_count_map = {}
for i in range(N):
    in_value = int(input())
    values[i] = in_value
    value_count = 0
    if in_value in value_count_map:
        value_count = value_count_map[in_value]
    value_count_map[in_value] = value_count + 1

max_value = max(value_count_map.keys())
value_count = value_count_map.pop(max_value)
if value_count == 1:
    next_max_value = max(value_count_map.keys())
for row in range(N):
    if value_count > 1:
        print(max_value)
    elif values[row] == max_value:
        print(next_max_value)
    else:
        print(max_value)
#! coding: UTF-8
data1 = list(map(int,input().split(" ")))
N = data1[0]
A = data1[1]
B = data1[2]
data2 = list(map(int,input().split(" ")))
data2.sort(reverse=True)
max_avr = sum(data2[:A])
max_avr /= A
a_num = 0
a_pos = 0
for i in range(N):
	if data2[i] == data2[A-1]:
		a_num += 1
		if i < A:
			a_pos += 1
#確率統計nCr
import math
def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)
cnt = 0
if a_pos == A:
    while a_pos <= B:
        cnt += nCr(a_num,a_pos)
        a_pos += 1
else:
    cnt += nCr(a_num,a_pos)
print("{0:.6f}".format(max_avr))
print(int(cnt))


### FIXED CODE ###

#! coding: UTF-8
N,A,B = list(map(int,input().split(" ")))
V = list(map(int,input().split(" ")))
V.sort(reverse=True)
max_avr = sum(V[:A]) / A
a_num = V.count(V[A-1])
a_pos = V[:A].count(V[A-1])

#確率統計nCr
import math
def nCr(n,r):
    f = math.factorial
    return f(n) // f(r) // f(n-r)

if V[0] == V[A-1]:
    cnt = sum(nCr(a_num,i) for i in range(A,min(B,a_num)+1)) 
else:
    cnt = nCr(a_num,a_pos)
print("{0:.10f}".format(max_avr))
print(int(cnt))
a = int(input())
b = int(input())

if a * b % 2 == 0:
    print('Even')

else:
    print('Odd')

### FIXED CODE ###

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

if a[0] * a[1] % 2 == 0:
    print('Even')

else:
    print('Odd')
import math
import numpy as np
N,M = map(int,input().split())
S = input()
T = input()

L = N*M // math.gcd(N,M)

X = np.zeros(L, dtype=np.str)

for i in range(N):
    X[i*(L//N)] = S[i]

for i in range(M):
    if X[i*(L//M)] == '':
        X[i*(L//M)] = T[i]
    elif X[i*(L//M)] != T[i]:
        print('-1')
        exit()

print(L)

### FIXED CODE ###

N,M = map(int,input().split())
S = input()
T = input()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

L = N*M // gcd(N,M)

n = L // N
m = L // M

list_n = [i for i in range(0,L,n)]
list_m = [i for i in range(0,L,m)]

list_common = sorted(list(set(list_n) & set(list_m)))

for i in list_common:
    if i == 0:
        if S[0] != T[0]:
            print('-1')
            exit()
    elif S[i//n] != T[i//m]:
        print('-1')
        exit()

print(L)
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
seq = (a,b,c,d,e)
data = list(itertools.combinations(seq,2))
print(data)
result = 0
for i in range(len(data)):
    if data[i][0] < data[i][1]:
        if data[i][1] - data[i][0] < k:
        result +=1
    else:
        if data[i][0] - data[i][1] < k:
        result +=1
if result == len(data):
    print('Yay!')
else:
    print(':(')




### FIXED CODE ###

import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
seq = (a,b,c,d,e)
data = list(itertools.combinations(seq,2))
result = 0
for i in range(len(data)):
    if data[i][0] < data[i][1]:
        if data[i][1] - data[i][0] <= k:
            result +=1
    else:
        if data[i][0] - data[i][1] <= k:
            result +=1
if result == len(data):
    print('Yay!')
else:
    print(':(')
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
flag = 1
cur0 = 0
cur1 = 0
cur2 = 0
cnt = 0
for i in range(1,N):
    if A[i]>A[i-1]:
        flag += 1
        if flag==1:
            cur1 = i
        elif flag==2:
            cur2 = i
        elif flag==3:
            cnt = max(cnt,i-cur0)
            cur0 = cur1
            cur1 = cur2
            flag -= 1
            cur2 = i
cnt = max(cnt,n-cur0)
print(cnt)

### FIXED CODE ###

from bisect import bisect_left,bisect_right
N = int(input())
A = sorted(list(map(int,input().split())))
G = {i:0 for i in range(10**5)}
cntmax = 0
for i in range(10**5):
    ind0 = bisect_left(A,i-1)
    ind1 = bisect_right(A,i+1)
    cntmax = max(cntmax,ind1-ind0)
print(cntmax)
s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
for i in range(j,len(s)):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b=map(int,input().split())
print((a+b+1)//2)
K, T = map(int, input().split())
A = [int(a) for a in input().split()]
A.sort()
sumA = 0
for a in A[:N-1]: sumA += a
print(max(0, A[N-1] - 1 - sumA))

### FIXED CODE ###

K, T = map(int, input().split())
A = [int(a) for a in input().split()]
A.sort()
sumA = 0
for a in A[:T-1]: sumA += a
print(max(0, A[T-1] - 1 - sumA))
T = input()
ans = []
if T[0]=='?':
    T[0]='D'

for i in range(len(T)-1):
    flg = 1
    if T[i+1]!='?':
        if T[i] != '?':
            ans.append(T[i])
            continue
        else:
            tmp = ans[i-1]
            flg = 0

    if flg:
        tmp = ans[i-1]
    if tmp=='P':
        ans.append('D')
    else:
        ans.append('P')



if T[-1]=='?':
    if ans[-1]=='P':
        ans.append('D')
    else:
        ans.append('P')
else:
    ans.append(T[-1])
print(''.join(ans))


### FIXED CODE ###

T = str(input())

ans = []
for i in T:
    if i == '?':
        ans.append('D')
    else:
        ans.append(i)

print(''.join(ans))
A,B,C,D,E=map(int,input().split())
a=A
b=B
c=C
d=D
    if a == 0:
        print(1)
    elif b == 0:
        print(2)
    elif c == 0:
        print(3)
    elif d == 0:
        print(4)
    else e == 0:
        print(5)


### FIXED CODE ###

A,B,C,D,E=map(int,input().split())

if A == 0:
    print(1)
elif B == 0:
    print(2)
elif C == 0:
    print(3)
elif D == 0:
    print(4)
else:
    print(5)
import sys
import os
f = open('../../input.txt', 'r')
sys.stdin = f

n, m = map(int, input().split())
uv = [list(map(int, input().split())) for _ in range(m)]
s,t = map(int, input().split())

before_dict = {}
after_dict = {}
after_3 = {}

for i in range(1,n+1):
    before_dict[i] =[]
    after_dict[i] = []
    after_3[i] = []

for i in range(m):
    u, v = uv[i]
    before_dict[v].append(u)
    after_dict[u].append(v)

for i in range(m):
    u, v = uv[i]
    for j in before_dict[u]:
        for k in after_dict[v]:
            if( j != k):
                after_3[j].append(k)

from collections import deque
d = deque()
d.append(s)

length = [-1] * (n+1)
length[s] = 0

check = True

while(check):
    if(len(d) == 0):
        break
    num = d.popleft()
    for i in after_3[num]:
        if(length[i] == -1):
            length[i] = length[num] + 1
            d.append(i)

    if(length[t] > -1):
        break

print(length[t])


### FIXED CODE ###

n, m = map(int, input().split())
uv = [list(map(int, input().split())) for _ in range(m)]
s, t = map(int, input().split())

next_dict = {}

for i in range(1,n*3 + 1):
    next_dict[i] = []

for i in range(m):
    u,v = uv[i]
    for j in range(3):
        next_dict[u + (j * n)].append((v + ((j+1)%3 * n )))

from collections import deque
d = deque()
d.append(s)

length = [-1] * (3*n + 1)
length[s] = 0

while(True):
    if(len(d) == 0):
        break

    num = d.popleft()
    for i in next_dict[num]:
        if( length[i] == -1 ):
            d.append(i)
            length[i] = length[num] + 1

    if(length[t] != -1):
        break

print(length[t] // 3)
N = int(input())
A = []
ans = 0
for i in range(0, N):
    A.append(int(input()))
    ans += A[i]
A.sort()
if (ans % 10) != 0:
    print(ans)
else:
    s = [a for a in A if a % 10 != 0]
    print(ans-s[0])


### FIXED CODE ###

N = int(input())
A = []
ans = 0
for i in range(0, N):
    A.append(int(input()))
    ans += A[i]
A.sort()
if (ans % 10) != 0:
    print(ans)
else:
    s = [a for a in A if a % 10 != 0]
    if len(s) == 0:
        print(0)
    else:
        print(ans-s[0])
from math import factorial

modulo = 10 ** 9 + 7

N, K = map(int, input().split())
adj = {a: [] for a in range(1, N + 1)}
for i in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

def P(n, k):
    return factorial(n) // factorial(n - k) if n >= k else 0

visited = set()

def ncoloring(root, d):
    """the number of coloring of a subtree at depth d
       when the color of the root has been decided."""
    visited.add(root)
    children = [s for s in adj[root] if s not in visited]
    remainingcolors = K - 2 if d > 0 else K - 1

    # coloring of the children
    p = P(remainingcolors, len(children)) % modulo

    # coloring of the subtrees
    for c in children:
        p = p * ncoloring(c, d + 1) % modulo
    return p

print(ncoloring(1, 0) * K % modulo)


### FIXED CODE ###

from collections import deque

modulo = 10 ** 9 + 7

N, K = map(int, input().split())
adj = {a: [] for a in range(1, N + 1)}
for i in range(N - 1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

def P(n, k):
    if n < k:
        return 0
    f = 1
    for i in range(n, n - k, -1):
        f = f * i % modulo
    return f

visited = set()
q = deque([1])
ncoloring = K  # num of coloring of the root

while len(q) > 0:
    u = q.popleft()
    visited.add(u)

    # coloring of the children
    children = [c for c in adj[u] if c not in visited]
    ncoloring *= P(K - 1 if u == 1 else K - 2, len(children))
    ncoloring %= modulo

    q.extend([c for c in children])

print(ncoloring)
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    a,b = inputMap()
    
    if a == "H":
        if b == "H":
            print("H")
        else:
            print("D")
    else:
        if b == "H":
            print("D")
        else:
            print("H")
    
    
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    a,b = map(str, input().split())
    
    if a == "H":
        if b == "H":
            print("H")
        else:
            print("D")
    else:
        if b == "H":
            print("D")
        else:
            print("H")
    
    
if __name__ == "__main__":
	main()
from sys import stdin, stdout
cnt=0
def check(a,b):
    global cnt
    for i in range(len(a)):
        cnt-=a[i][0]
        if cnt<0:
            return False
        cnt+=a[i][1]

    for i in range(len(b)):
        cnt-=b[i][0]
        if cnt<0:
            return False
        cnt+=b[i][1]
    if cnt==0:
        return True
    return False

a=[]
b=[]
for i in range(int(input())):
    s=stdin.readline().strip()
    #print(s)
    ans=''
    for j in range(len(s)):
        if s[j]=='(':
            ans+='('
        else:
            if len(ans)==0:
                ans+=')'
                continue
            if ans[-1]=='(':
                ans=ans[:-1]
            else:
                ans+=')'
    L=0
    for j in range(len(ans)):
        if ans[j]==')':
            L+=1
        else:
            break
    R=len(ans)-L
    if L<R:
        a.append((L,R))
    else:
        b.append((L,R))

    a.sort()
    b.sort(key=lambda x:x[1],reverse=True)
    #print(a,b)
if check(a,b):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

#int(input())
#int(x) for x in input().split()
#map(int,input().split())
x=input()
y=input()
if x==y[:-1]:
	print('Yes')
else:
	print('No')
a, b = map(int(), input().split())
if a - b * 2 > 0:
  print(a-b*2)
else:
  print(0)


### FIXED CODE ###

a, b = map(int, input().split())
if a - b * 2 > 0:
  print(a-b*2)
else:
  print(0)
#ABC066C
n=int(input())
a=list(map(int, input().split()))
front=[]
back=[]
flg=n%2
for i in range(n//2):
    front.insert(0, a[2*i-flg+1])
    #back.append(a[2*i+flg])
back=[a[2*i+flg] for i in range(n)]
if flg==1:
    front.insert(0, a[n-1])
print(' '.join(map(str, front+back)))

### FIXED CODE ###

#ABC066C
n=int(input())
a=list(map(int, input().split()))
flg=n%2
half=n//2
front=[0]*(half+flg)
back=[0]*(half)
for i in range(half):
    front[half+flg-1-i]=a[2*i-flg+1]
    back[i]=a[2*i+flg]
if flg==1:
    front[0]=a[n-1]
print(' '.join(map(str, front+back)))
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(n)]
inf = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) >0 else inf
    ret0 = dfs(cur+1, a,b,c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) +10
    ret3 = dfs(cur+1, a,b,c+l[cur]) +10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

### FIXED CODE ###

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a, b, c) >0 else inf
    ret0 = dfs(cur+1, a,b,c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) +10
    ret3 = dfs(cur+1, a,b,c+l[cur]) +10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
a=a.split(' ')
for b in range(n):
    a[b]=int(a[b])

m=0
for b in range(n-1):
    if m<=a[b+1]-a[b]:
        m=a[b+1]-a[b]

if m<=k-a[n-1]+a[0]:
    m=k-a[n-1]+a[0]

print(k-m)

### FIXED CODE ###

k,n=map(int,input('').split())
a=input('')
a=a.split(' ')
for b in range(n):
    a[b]=int(a[b])
a.sort()

m=0
for b in range(n-1):
    if m<=a[b+1]-a[b]:
        m=a[b+1]-a[b]

if m<=k-a[n-1]+a[0]:
    m=k-a[n-1]+a[0]

print(k-m)
N = int(input())
p = [[0,0]]*N
for i in range(N):
  p[i] = input().split()
  p[i] = list(map(int,p[i]))
p = sorted(p,key = lambda x:x=p[1])
s = [0]*N
s[0] = p[0][0]
for i in range(N-1):
  s[i+1] = s[i] + p[i+1][0]
k = 0
for i in range(N):
  if s[i] <= p[i][1]:
    k = k + 1
  else:
    print('No')
    break
if k == N:
  print('Yes')

### FIXED CODE ###

N = int(input())
p = [[0,0]]*N
for i in range(N):
  p[i] = input().split()
  p[i] = list(map(int,p[i]))
p = sorted(p,key = lambda p:p[1])
s = [0]*N
s[0] = p[0][0]
for i in range(N-1):
  s[i+1] = s[i] + p[i+1][0]
k = 0
for i in range(N):
  if s[i] <= p[i][1]:
    k = k + 1
  else:
    print('No')
    break
if k == N:
  print('Yes')
n,m=map(int,input().split())
p=[]
s=[]
idx=0
AC=0
WA=0
for i in range(m):
    p_,s_=input().split()
    p.append(int(p_))
    s.append(s_)
for i in range(m):
    cp=p.count(p[idx])
    for i in range(idx,(cp+idx)):
        ##print(i)
        if s[i]=='WA':
            WA+=1
        elif s[i]=='AC':
            AC+=1
            break
    idx=cp+idx
    if idx==m:
        break
print("{} {}".format(AC,WA))


### FIXED CODE ###

n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)
    if ac[p-1] == 1:
        continue
    if s=='AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
AC=0
WA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
        WA += wa[i]
print("{} {}".format(AC,WA))
a=input()

def prime(n):
  if n <= 1:
    return False
  else:
    for i in range(2,n):
      if n%i == 0:
      	return False
      return True
    
while prime(a)==False:
  a += 1

print(a)

### FIXED CODE ###

a=int(input())

def prime(n):
  if n <= 1:
    return False
  else:
    for i in range (2,n):
      if n%i == 0:
        return False
    return True
        
while prime(a)==False:
    a += 1

print(a)
from bisect import *
N,M=map(int,input().split())
kagi=[]
for i in range(M):
    a,b=map(int,input().split())
    C=list(map(int,input().split()))
    for i in range(b):
        C[i]-=1
    kagi.append([a,set(C)])

value=10**7
idx=-1
for i in range(M):
    if 0 in kagi[i][1] and kagi[i][0]<value:
        value=kagi[i][0]
        idx=i
if idx==-1:
    print(-1)
    exit()
kagilst=[idx]

takara=[set() for i in range(N)]
for m in range(M):
    for k in kagi[m][1]:
        takara[k].add(m)

for n in range(1,N):
    if [k for k in kagilst if n in kagi[k][1]]:
        continue
    tempvalue=10**7
    for i in range(len(kagilst)**2):

        for k in takara[n]:
            lst=[0 for x in range(n)]
            for z in kagilst+[k]:
                for m in kagi[z][1]:
                    if m<len(lst):
                        lst[m]=1
            A=bin(i)[:2]
            A=list(reversed(list(A)))
            for i in range(len(A)-len(kagilst)):
                A.append("0")
            for a in range(len(kagilst)):

                if A[a]=="1":
                    for h in kagi[kagilst[a]][1]:
                        if h<len(lst):
                            lst[h]=1
            if not 0 in lst:
                temptempvalue=value+sum([kagi[a][0] for a in range(len(kagilst)) if A[a]=="1"])+kagi[k][0]
                if temptempvalue<tempvalue:
                    tempvalue=temptempvalue
                    tempkagi=k

    if tempvalue==10**7:
        print(-1)
        exit()
    value=tempvalue
    kagilst.append(k)
print(value)


### FIXED CODE ###

from bisect import *
N,M=map(int,input().split())
kagi=[]
for i in range(M):
    a,b=map(int,input().split())
    C=list(map(int,input().split()))
    value=0
    for i in range(b):
        C[i]-=1
        value+=2**C[i]

    kagi.append([a,value])


dp=[[10**8 for i in range(2**N)] for m in range(M+1)]
dp[0][0]=0
for i in range(M):
    for s in range(2**N):
        dp[i+1][s]=min(dp[i][s],dp[i+1][s])
        dp[i+1][s|kagi[i][1]]=min(dp[i+1][s|kagi[i][1]],dp[i][s]+kagi[i][0])
if 10**8==dp[M][-1]:
    print(-1)
else:
    print(dp[M][-1])