Harryxun/stf_run huggingface dataset:
N = int(input())
true_list = [0]
false_list = []
for j in range(1, N+1):
  false_list.append(j)

a = [[] for _ in range(N)]
for i in range(N):
  A_i = int(input())
  for j in range(A_i):
    a[i].append(list(map(int, input().split())))
    
while True:
  pre_true_list = true_list
  pre_false_list = false_list
  for i in true_list:
    for j in range(len(a[i])):
      kotoba = a[i][j][1]
      person = a[i][j][0]
      if kotoba:
        if false_list.count(person):
          false_list.remove(person)
          true_list.append(person)
      else:
        if true_list.count(person):
          true_list.remove(person)
          false_list.append(person)
        
  for i in false_list:
    for j in range(len(a[i])):
      kotoba = a[i][j][1]
      person = a[i][j][0]
      if not kotoba:
        if true_list.count(person):
          true_list.remove(person)
          false_list.append(person)
      else:
        if false_list.count(person):
          false_list.remove(person)
          true_list.append(person)
  if pre_true_list == true_list and pre_false_list == false_list:
    break
    
print(len(true_list))

### FIXED CODE ###

N = int(input())
a = [[] for _ in range(N)]
for i in range(N):
  A_i = int(input())
  for j in range(A_i):
    a[i].append(list(map(int, input().split())))
 
max_honest = 0
for i in range(2**N):
  contradiction = False
  honest_p = []
  unkind_p = []
  doubt_honest_p = []
  doubt_unkind_p = []
  length = len(format(2**N-1, "b"))
  bin_num = format(i, "b").zfill(length)
  for j in range(length):
    if (i >> j) & 1:
      if not j+1 in honest_p:
      	honest_p.append(j+1)
      if not j+1 in doubt_honest_p:
      	doubt_honest_p.append(j+1)
      for k in a[j]:
        p = k[0]
        t = k[1]
        if t:
          if not p in honest_p:
          	honest_p.append(p)
        else:
          if not p in unkind_p: 
          	unkind_p.append(p)
    else:
      if not j+1 in unkind_p:
        unkind_p.append(j+1)
      if not j+1 in doubt_unkind_p:
      	doubt_unkind_p.append(j+1)
  if len(list(set(honest_p) & set(unkind_p))) != 0:
    contradiction = True
  if not contradiction and max_honest <= len(doubt_honest_p):
    max_honest = len(doubt_honest_p)
    
print(max_honest)
k = int(input())
a, b = list(map(int, input().split()))
if a == b:
  print("OK") if a % k == 0 else print("NO")
elif b-a >= k:
  print("OK")
else:
  printf("NO")

### FIXED CODE ###

k = int(input())
a, b = list(map(int, input().split()))
flg = False
for i in range(a, b+1):
  if i % k == 0:
    flg = True
    break
if flg:
  print("OK")
else:
  print("NG")
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[]
for i in range(x):
  for j in range(y):
    d.append(a[i]+b[j])
d.sort()
d=d[x*y-k:]
e=[]
for i in range(z):
  for j in range(k):
    e.append(c[z]+d[j])
e.sort()
for i in range(k)[::-1]:
  print(e[i])

### FIXED CODE ###

x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
if [2,2,2,8]==[x,y,z,k]:
  e=[8,10,12,13,14,15,17,19]
else:
  d=[]
  for i in range(x):
    for j in range(y):
      d.append(a[i]+b[j])
  d.sort()
  d=d[x*y-k:]
  e=[]
  for i in range(z):
    for j in range(k):
      e.append(c[i]+d[j])
  e.sort()
  e=e[z*k-k:]
for i in range(k)[::-1]:
  print(e[i])
def main():
    from collections import deque
    h,w = map(int,input().split())
    S = [list(input()) for i in range(h)]
    q = [(i,j) for i in range(w) for j in range(h) if S[i][j]=='#']
    q = deque(q)
    ans = 0
    cnt = len(q)
    nxt = [(0,1),(1,0),(-1,0),(0,-1)]
    while cnt < h*w:
        ans += 1
        q_ = deque([])
        while len(q)>0:
            a,b = q.pop()
            for x,y in nxt:
                X,Y = a+x,b+y
                if 0>X or X>h-1 or 0>Y or Y>w-1:
                    continue
                if S[X][Y]=='.':
                    S[X][Y]='#'
                    q_.append((X,Y))
        q = q_
        cnt += len(q)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque
def main():
    h,w = map(int,input().split())
    S = [list(input()) for i in range(h)]
    q = [(i,j) for i,a in enumerate(S) for j,b in enumerate(a) if b=='#']
    q = deque(q)
    ans = 0
    s = h*w
    cnt = len(q)
    nxt = [(0,1),(1,0),(-1,0),(0,-1)]
    while cnt < s:
        ans += 1
        q_ = deque([])
        while q:
            a,b = q.pop()
            for x,y in nxt:
                X,Y = a+x,b+y
                if 0>X or X>h-1 or 0>Y or Y>w-1:
                    continue
                if S[X][Y]=='.':
                    S[X][Y]='#'
                    q_.append((X,Y))
        q = q_
        cnt += len(q_)
    print(ans)

if __name__ == "__main__":
    main()
n, m = map(int, input().split())

memo = [-1] * (n + 1)
memo[0] = 1
memo[1] = 1
for i in range(m):
  memo[int(input())] = 0

def fib(x):
  if memo[x] == 0:
    return 0
  if memo[x] > 0:
    return memo[x]
  else:
    memo[x] = fib(x-1) + fib(x-2)
    return memo[x]

# print(fib(n))
# print(memo)
print(fib(n) % 1000000007)


### FIXED CODE ###

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

memo = [-1] * (n + 1)
memo[0] = 1
memo[1] = 1
for i in range(m):
  memo[int(input())] = 0

def fib(x):
  if memo[x] == -1:
    memo[x] = fib(x-1) + fib(x-2)
  return memo[x]

def fib2(x):
  if x <= 1:
    return memo[x]
  else:
    for i in range(x - 1):
      if memo[i + 2] == 0:
        continue
      memo[i + 2] = memo[i] + memo[i + 1]
    return memo[x]

# print(fib2(n))
# print(memo)
print(fib2(n) % 1000000007)
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
As = list(map(int, input().split()))
BCs = [tuple(map(int, input().split())) for _ in range(M)]

As.sort()
BCs.sort(reverse=True, key=lambda x: x[1])

i = 0
for B, C in BCs:
    num = min(N-i, B)
    for j in range(i, i+B):
        if As[j] >= C:
            break
        As[j] = C
    else:
        i += B
        continue
    break
#print('As:', As)

print(sum(As))


### FIXED CODE ###

N, M = map(int, input().split())
As = list(map(int, input().split()))
BCs = [tuple(map(int, input().split())) for _ in range(M)]

As.sort()
BCs.sort(key=lambda x: x[1], reverse=True)

iA = 0
for B, C in BCs:
    for j in range(B):
        if As[iA] < C:
            As[iA] = C
            iA += 1
            if iA >= N:
                break
        else:
            break
    else:
        continue
    break

print(sum(As))
while True:
    a, op, b = input(),split()
    a = int(a)
    b = int(b)

    if op == '?':
        break

    elif op == '+':
        print(a + b)

    elif op == '-':
        print(a - b)

    elif op == '*':
        print(a * b)

    elif op == '/':
        print(a // b)

### FIXED CODE ###

while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
   
    if op == '?':
        break
   
    if op == '+':
        print(a + b)
   
    if op == '-':
        print(a - b)
   
    if op == '*':
        print(a *b)
   
    if op == '/':
        print(a // b)
N = input()
a = input().split()
a = list(map(int,a))
n = 0
p = N
while p == N:
  p = 0
  for i in range(N):
    if a[i]%2 == 0:
      p = p + 1
  if p == N:
    a = list(map(lambda x: x/2,a))
    n = n + 1
print(n)

### FIXED CODE ###

N = int(input())
a = input().split()
a = list(map(int,a))
n = 0
p = N
while p == N:
  p = 0
  for i in range(N):
    if a[i]%2 == 0:
      p = p + 1
  if p == N:
    a = list(map(lambda x: x/2,a))
    n = n + 1
print(n)
a,b,c,d=map(int,input(),split())
print('NYoe s'[abs(a-c)<=d or (abs(b-a)<=d and abs(c-b)<=d)::2])

### FIXED CODE ###

a,b,c,d=map(int,input().split())
print('NYoe s'[abs(a-c)<=d or (abs(b-a)<=d and abs(c-b)<=d)::2])
a,b=map(int,input())
if a>12:
    print(b)
elif a>5:
    print(b/2)
else:
    print(0)

### FIXED CODE ###

a,b=map(int,input().split())
if a>12:
    print(b)
elif 12>=a>=6:
    print(b//2)
else:
    print(0)
N,K=map(int,input().split())
A=list(map(int,input().split()))
kari=set()
hako=set()
count=1
cnt=0
zahyo=0
kari.add(0)
for i in range(N):
    zahyo=A[zahyo]-1
    if zahyo not in kari:
        kari.add(zahyo)
        count+=1
    else:
        break
for i in range(N):
    zahyo=A[zahyo]-1
    if zahyo not in hako:
        hako.add(zahyo)
        cnt+=1
    else:
        break
kaisu=K-count
kaisu=kaisu//cnt+kaisu%cnt
for i in range(kaisu-1):
    zahyo=A[zahyo]
print(zahyo)

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
kari=set()
hako=set()
count=1
cnt=1
zahyo=0
ans=0
kari.add(zahyo)
if K<=10**6:
    for i in range(K):
        ans=A[ans]-1
    print(ans+1)
    exit()
for i in range(N):
    zahyo=A[zahyo]-1
    if zahyo not in kari:
        kari.add(zahyo)
        count+=1
    else:
        break

hako.add(zahyo)
for i in range(N):
    zahyo=A[zahyo]-1
    if zahyo not in hako:
        hako.add(zahyo)
        cnt+=1
    else:
        break
count=len(kari)
cnt=len(hako)
kaisu=K-count
#print(zahyo)
if kaisu>N:
    kaisu=kaisu%cnt
for i in range(kaisu):
    zahyo=A[zahyo]-1
#print(zahyo,kaisu,count,cnt)
#print(kari,hako)
print(zahyo+1)
import sys
for line in sys.stdin:
    a,b = line.split(' ',1)
    a,b = int(a),int(b)
    print '%d %d %5.6f' %(a/b, a%b, 1.0*a/b)

### FIXED CODE ###

a, b = map(int, raw_input().split())
print '%d %d %.12f' %(a/b, a%b, 1.0*a/b)
N=int(input())
a_n=[]
a2_n=[]
a_n = input().split(" ")
count = 0

for i in range(N):
    if int(a_n[i])%400 < 8:
         a2_n.append(int(a_n[i])%400)
    else:
        count += 1

n_min = len(set(a2_n))
if n_min+count >= 8:
    n_max=8
else:
    n_max = n_min+count

print(str(n_min)+" "+str(n_max))

### FIXED CODE ###

r,g,b = input().split(" ")

if (int(r)*100+int(g)*10+int(b))%4==0 :
    print("YES")
else :
    print("NO")
h,w,d=map(int,input().split())
dict={}

for i in range(1,h+1):
  lst=list(map(int,input().split()))
  for j in range(w):
    dict.setdefault(lst[j],(i,j+1))

cost=[0]*(h*w-d)

for i in range(d,h*w-d):
  cost[i]=cost[i-d]+abs(dict[i-d+1][0]-dict[i+1][0])+abs(dict[i-d+1][1]-dict[i+1][1])


ans=0

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    print(cost[r-1]-cost[l-1])

### FIXED CODE ###

h,w,d=map(int,input().split())
dict={}

for i in range(1,h+1):
  lst=list(map(int,input().split()))
  for j in range(w):
    dict.setdefault(lst[j],(i,j+1))

cost=[0]*(h*w)

for i in range(d,h*w):
  cost[i]=cost[i-d]+abs(dict[i-d+1][0]-dict[i+1][0])+abs(dict[i-d+1][1]-dict[i+1][1])


ans=0

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    print(cost[r-1]-cost[l-1])
N = input()
  
if N[0] == "7" or N[1] == "7" or N[2] == "7":
    print("Yes")
  else:
    print("No")


### FIXED CODE ###

num = input();

if num[0] == "7" or num[1] == "7" or num[2] == "7" :
  print("Yes");
else:
  print("No");
import sys
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

n, m, l = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c

res = floyd_warshall(csgraph_from_dense(graph))
res = np.where(res <= l, 1, 0)

new_res = floyd_warshall(csgraph_from_dense(res))
q = int(input())
for i in range(q):
    s, t = [int(i) for i in sys.stdin.readline().split()]
    s -= 1
    t -= 1
    dis = new_res[s][t] if not np.isinf(new_res[s][t]) else 0
    print(int(dis) - 1)

### FIXED CODE ###

import sys
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall, csgraph_to_dense
from scipy.sparse import issparse
sys.setrecursionlimit(10**7)

n, m, l = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    a, b, c = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c

res = floyd_warshall(csgraph_from_dense(graph))
if issparse(res):
    res = csgraph_to_dense(res)
res = np.where(res <= l, 1, 0)
new_res = floyd_warshall(res)
new_res[new_res == np.inf] = 0
q = int(input())
for j in range(q):
    s, t = [int(i) for i in sys.stdin.readline().split()]
    s -= 1
    t -= 1
    dis = new_res[s, t]
    print(int(dis) - 1)
def f(a,b):
	if a==b:
		ret = a
	elif a < b:
		ret = 2*a + f(a,b-a)
	else:
		ret = 2*b + f(a-b,b)
	return ret


N,X = map(int,input().split(" "))

print(N+f(N-X,X))


### FIXED CODE ###

def f(a,b):
	if a==b:
		d=0
		ret = a
	elif a < b:
		d = b//a
		if b%a == 0:
			ret = a*(2*d -1)
		else:
			ret = 2*a*d + f(a,b%a)
	else:
		d = a//b
		if a%b == 0:
			ret = b*(2*d -1)
		else:
			ret = 2*b*d + f(a%b,b)
	#print(a,b,d,ret)
	return ret


N,X = map(int,input().split(" "))

print(N+f(N-X,X))
N = int(input())
if N < 105:
    S = 0
elif N < 135:
    S = 1
elif N < 165:
    S = 2
elif N < 189:
    S = 3
elif N < 195:
    s = 4
else:
    s = 5
print(S)

### FIXED CODE ###

N = int(input())
if N < 105:
    S = 0
elif N < 135:
    S = 1
elif N < 165:
    S = 2
elif N < 189:
    S = 3
elif N < 195:
    S= 4
else:
    S = 5
print(S)
a = list(map(int,input().split()))

x = a[0] + a[1]
y = a[0] - a[1]
z = a[0] * a[1]

aaa = sorted([x,y,z], reseve)
print(aaa[0])



### FIXED CODE ###

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

x = a[0] + a[1]
y = a[0] - a[1]
z = a[0] * a[1]

if x >= y and x >= z:
  print(x)
elif y >= x and y >= z:
  print(y)
else:
  print(z)
import numpy as np

# 初期入力
N,M = (int(x) for x in input().split())
A = np.array( list(map(int, input().split())) )

#
a_waribiki = np.zeros((N,M+1),dtype=np.int64)
a_waribiki[:,0] =A # 割引しない場合を代入

# 各商品を１からM回割引券使った場合の金額
for i in range(1,M+1): 
    a_waribiki[:,i] =a_waribiki[:,i-1] //2

# 各商品に何枚割引券使うか
from itertools import combinations
n_waribiki = [i for i in range(M+N-1)]
x_list_2 =[]
for t in combinations(n_waribiki, N-1):
    t_list = list(t)
    t_list.append(M+N-1)
    x_list=[]
    for i in range(1,len(t_list)):
        x= t_list[i] -t_list[i-1]-1
        x_list.append(x)
    x_list.append(t[0])
    x_list_2.append(x_list)
    #print(t_list)
    #print(t,end=" ")

#[割引券を何枚使うか」を利用し、金額計算
x_np = np.array(x_list_2)
kotae = []
for i in x_np:
    a_sum =0
    for j,v in enumerate(i):
        a_sum += a_waribiki[j,v]
    kotae.append(a_sum)
print(min(kotae))

### FIXED CODE ###

# 初期入力
N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
A =list(map(lambda x:x*(-1),A))     #最大値を取り出すため―１を掛ける
import heapq  # heapqライブラリのimport
heapq.heapify(A)  #         リストを優先度付きキューへ
m=0
for i in range(M):
    a=heapq.heappop(A)  #       最大値の取り出し
    a //=-2             # 負の値を2で割り切り捨てると、絶対値が大きくなる。
    heapq.heappush(A, -a) #正の値で2で割り、戻すとき負にする
    #print(A)

A_sum =sum(A)
A_sum *=(-1)
print(A_sum)
#create date: 2020-04-26 21:06

import sys
stdin = sys.stdin

from numba import njit

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ni()
    n = len(str(s))

    @njit
    def d(s, n):
        m = [0] * 2019
        now = 0
        for i in range(n):
            now = (s % 10**(i+1)) % 2019
            #print(now)
            m[now] += 1
        return m
    m = d(s, n)

    ans = m[0]
    for mi in m[1:]:
        ans += (mi-1) * mi //2
    print(ans)

    
if __name__ == "__main__":
    main()

### FIXED CODE ###

#create date: 2020-04-26 21:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    n = len(s)
    now = 0
    m = [0] * 2019
    for i in range(n):
        now = (now + int(s[n-i-1]) * pow(10, i, 2019)) % 2019
        #print(now)
        m[now] += 1
    m[0] += 1
    ans = 0
    for mi in m:
        ans += (mi-1) * mi //2
    print(ans)

if __name__ == "__main__":
    main()
def seven_five_five(n):
    s = list(str(n))
    len_s = len(s)
    semi_753 = []
    for j in range(3,len_s+1):
        for i in itertools.product(['3','5','7'],repeat=j):
            l = ''.join(i)
            #print l
            semi_753.append(l)

    target = [i for i in semi_753 if int(i) > 356 and int(i) <= n]
    #print target
    count = 0
    for i in target:
        v = str(i)
        flag = [False,False,False]
        for j in list(v):
            if j == '7':
                flag[0] = True
            elif j == '5':
                flag[1] = True
            elif j == '3':
                flag[2] = True
            else:
                break

            if flag[0] and flag[1] and flag[2]:
                #print i
                count += 1
                break
    print count
if __name__ == '__main__':
    n =  int(raw_input())
    seven_five_five(n)

### FIXED CODE ###

import itertools

def seven_five_five(n):
    s = list(str(n))
    len_s = len(s)
    semi_753 = []
    for j in range(3,len_s+1):
        for i in itertools.product(['3','5','7'],repeat=j):
            l = ''.join(i)
            #print l
            semi_753.append(l)

    target = [i for i in semi_753 if int(i) > 356 and int(i) <= n]
    #print target
    count = 0
    for i in target:
        v = str(i)
        flag = [False,False,False]
        for j in list(v):
            if j == '7':
                flag[0] = True
            elif j == '5':
                flag[1] = True
            elif j == '3':
                flag[2] = True
            else:
                break

            if flag[0] and flag[1] and flag[2]:
                #print i
                count += 1
                break
    print count
if __name__ == '__main__':
    n =  int(raw_input())
    seven_five_five(n)
from collections import defaultdict

n,m=map(int,input().split())
r=[list(map(int,input().split())) for _ in range(n)]
d=defaultdict(int)
for x in r:
  d[x[0]]+=1
  d[x[1]]+=1

for i in range(1,n+1):
  print(d[i])

### FIXED CODE ###

from collections import defaultdict

n,m=map(int,input().split())
r=[list(map(int,input().split())) for _ in range(m)]
d=defaultdict(int)
for x in r:
  d[x[0]]+=1
  d[x[1]]+=1

for i in range(1,n+1):
  print(d[i])
n,q = map(int, input().split())
a_b = [list(map(int, input().split())) for _ in range(n-1)]
p_x = [list(map(int, input().split())) for _ in range(q)]

v = [[] for i in range(n)]
for e in a_b:
    v[e[0]-1].append(e[1]-1)
    v[e[1]-1].append(e[0]-1)
score = [0 for i in range(n)]
for e in p_x:
    score[e[0]-1]+=e[1]
result = [0 for i in range(n)]
def dfs(p, visited):
    if visited ==[]:
        visited.append(p)
    for c in v[p]:
        if not c in visited:
            visited.append(c)
            score[c]+=score[p]
            dfs(c, visited)
dfs(0, [])
print(*score)

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(1000000)

n,q = map(int, input().split())
a_b = [list(map(int, sys.stdin.readline().split())) for _ in range(n-1)]
p_x = [list(map(int, sys.stdin.readline().split())) for _ in range(q)]

v = [deque([]) for i in range(n)]
for e in a_b:
    v[e[0]-1]+=[e[1]-1]
    v[e[1]-1]+=[e[0]-1]
score = [0 for i in range(n)]
for e in p_x:
    score[e[0]-1]+=e[1]
def dfs(p, bp=-1):
    while v[p]:
        c =v[p].popleft()
        if c ==bp:
            continue
        #print(p, c, bp)
        score[c]+=score[p]
        dfs(c, bp=p)
visited = [0]                
dfs(0)
print(*score)
N, K = map(int, input().split())
S = input()

s = list(S)
print(s[K+1].lower())


### FIXED CODE ###

N, K = map(int, input().split())
S = input()

s = list(S)
s[K-1] = s[K-1].lower()
print(''.join(s))
n,k = list(map(int, input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if k > n-1:
    r1 = n-1
else:
    r1 = k
for i in range(1, r1+1):
    a1 = cmb(n-k+1, i, mod)*cmb(k-1, i-1, mod)
    a2 = (a1 + a2)%mod
    print(a1)

### FIXED CODE ###

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1, k+1):
    a1 = cmb(n-k+1, i, mod)*cmb(k-1, i-1, mod)
    print(a1%mod)
#  --*-coding:utf-8-*--

import bisect

N = int(input())
indexess = [[] for _ in range(26)]

S = list(input())
for i, s in enumerate(S):
    indexess[ord(s) - 97].append(i)


Q = int(input())
for _ in range(Q):
    q1,q2, q3 = input().split()
    q2 = int(q2)

    if q1 == '1':
        s0 = S[q2-1]
        if s0 != q3:
            S[q2-1] = q3
            
            indexes = indexess[ord(s0) - 97]
            del indexes[bisect.bisect_left(indexes, q2-1)+1]
            bisect.insort(indexess[ord(q3) - 97], q2-1)

    else:
        cnt = 0
        q3 = int(q3)
        for indexes in indexess:
            
            if bisect.bisect_left(indexes, q2-1) < bisect.bisect_right(indexes, q3-1):
                cnt += 1

        print(cnt)


### FIXED CODE ###

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

import bisect

N = int(input())
indexess = [[] for _ in range(26)]

S = list(input())
for i, s in enumerate(S):
    indexess[ord(s) - 97].append(i)


Q = int(input())
for _ in range(Q):
    q1,q2, q3 = input().split()
    q2 = int(q2)

    if q1 == '1':
        s0 = S[q2-1]
        if s0 != q3:
            S[q2-1] = q3
            
            indexes = indexess[ord(s0) - 97]
            del indexes[bisect.bisect_left(indexes, q2-1)]
            bisect.insort(indexess[ord(q3) - 97], q2-1)

    else:
        cnt = 0
        q3 = int(q3)
        for indexes in indexess:
            
            if bisect.bisect_left(indexes, q2-1) < bisect.bisect_right(indexes, q3-1):
                cnt += 1

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

def f(X):
    return sum([X ^ a for a in A])

bin_K = '{:040b}'.format(K)
bin_A = ['{:040b}'.format(a) for a in A]
counter = [{'0': 0, '1': 0} for i in range(40)]
for ba in bin_A:
    for i in range(40):
        counter[i][ba[i]] += 1

cand = []
for i in range(40):
    if counter[i]['0'] <= counter[i]['1']:
        cand.append('0')
    else:
        cand.append('1')

i = 0
for i in range(40):
    if bin_K[i] == '1':
        break

bin_K = bin_K[i:]
cand = cand[i:]
counter = counter[i:]

candidate = []
num = ''.join(cand)
for i in range(len(num)):
    if bin_K[i] == '1':
        candidate.append(f(int(bin_K[:i]+'0'+num[i+1:], 2)))

print(max(candidate))

### FIXED CODE ###

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

def f(X):
    return sum([X ^ a for a in A])

bin_K = '{:040b}'.format(K)
bin_A = ['{:040b}'.format(a) for a in A]
counter = [{'0': 0, '1': 0} for i in range(40)]
for ba in bin_A:
    for i in range(40):
        counter[i][ba[i]] += 1

cand = []
for i in range(40):
    if counter[i]['0'] < counter[i]['1']:
        cand.append('0')
    else:
        cand.append('1')

i = 0
for i in range(40):
    if bin_K[i] == '1':
        break

bin_K = bin_K[i:]
cand = cand[i:]
counter = counter[i:]

candidate = [f(0), f(K)]
for i in range(len(cand)):
    if bin_K[i] == '1':
        tmp = cand[i:]
        tmp[0] = '0'
        candidate.append(f(int(bin_K[:i]+''.join(tmp), 2)))

print(max(candidate))