Harryxun/stf_run huggingface dataset:
def prod(li, MOD):
    ret = 1
    for a in li:
        ret *= a
        ret %= MOD
    return ret

N, K = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort(key=lambda x : abs(x))
pus = []
miu = []
for i in range(K):
    a = aaa.pop()
    if a >= 0:
        pus.append(a)
    else:
        miu.append(a)
if len(pus) == 0:
    if len(miu) % 2 == 1:
        aaa.extend(miu)
        aaa.sort(key=lambda x : abs(x))
        miu = aaa[:K]
elif len(miu) == 0:
    pass
elif len(miu) % 2 == 1:
    x = min(pus) if abs(min(pus)) > abs(max(miu)) else max(miu)
    if x >= 0 and all(a >= 0 for a in aaa):
        miu.pop()
        pus.append(aaa[-1])
        pus.append(aaa[-2])
    elif x < 0 and all(a <= 0 for a in aaa):
        pus.pop()
        miu.append(aaa[-1])
        miu.append(aaa[-2])
    else:
        if abs(pus[-1]) > abs(miu[-1]):
            miu.pup()
        else:
            pus.pop()
        for y in aaa[::-1]:
            if x * y <= 0:
                if y >= 0:
                    pus.append(y)
                else:
                    miu.append(y)

ans = 1
MOD = 1_000_000_007
ans = prod(pus, MOD) * prod(miu, MOD)
ans %= MOD
print(ans)


### FIXED CODE ###

def prod(li, MOD):
    ret = 1
    for a in li:
        ret *= a
        ret %= MOD
    return ret

N, K = map(int, input().split())
MOD = 1_000_000_007
aaa = list(map(int, input().split()))
if N == K:
    print(prod(aaa, MOD))
    exit()
aaa.sort(key=lambda x : abs(x))
if sum(a < 0 for a in aaa[-K:]) % 2 == 0:
    print(prod(aaa[-K:], MOD))
else:
    if all(a <= 0 for a in aaa):
        bbb = aaa[:K]
    else:
        try:
            x1, y1 = min([a for a in aaa[-K:] if a > 0]), min([a for a in aaa[:-K] if a < 0])
        except:
            x1, y1 = 1, 0
        try:
            x2, y2 = max([a for a in aaa[-K:] if a < 0]), max([a for a in aaa[:-K] if a >= 0])
        except:
            x2, y2 = 1, 0
        bbb = aaa[-K:]
        if abs(x2 * y1) > abs(x1 * y2):
            bbb.remove(x1)
            bbb.append(y1)
        else:
            bbb.remove(x2)
            bbb.append(y2)
    print(prod(bbb, MOD))
n = int(raw_input())
m = int(raw_input())
print( n*n - m )

### FIXED CODE ###

n = int(input())
m = int(input())
print( n*n - m )
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
  if v[i] > c[i]:
    ans + = (v[i]-c[i])
  else:
    continue
print(ans)

### FIXED CODE ###

n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
  if v[i] > c[i]:
    ans += (v[i]-c[i])
  else:
    continue
print(ans)
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
sumA = 0

for i in A:
    sumA = sumA + A[i]

if sumA > N:
    print(-1)
else:
    print(N-sumA)


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
sumA = 0
cnt = 0

for i in A:
    sumA = sumA + A[cnt]
    cnt = cnt +1

if sumA > N:
    print(-1)
else:
    print(N-sumA)
import sys
input = sys.stdin.readline
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)

def dfs(neighbor,start):
    global k
    if sum(visited) == N:
        return 0
    for i in neighbor[start]:
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            dfs(neighbor,i)


m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)
if N == 9999:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
dfs(neigh,nn)

ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
lis = list(map(int,input().split()))
if lis[0]+lis[1]>lis[2]+lis[3]:
  print("Left")
else if lis[0]+lis[1]<lis[2]+lis[3]:
  print("Right")
else:
  print("Balanced")

### FIXED CODE ###

lis = list(map(int,input().split()))
if lis[0]+lis[1]>lis[2]+lis[3]:
  print("Left")
elif lis[0]+lis[1]<lis[2]+lis[3]:
  print("Right")
else:
  print("Balanced")
n, k = int(input())
print(n % k)

### FIXED CODE ###

n, k = map(int, input().split())
n %= k
m = n
m -= k
m = abs(m)
n = min(n, m)
print(n)
import math
def c_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
for i in range(1,k+1):
    print((c_count(n-k+1,i)%(10**9+7)) * (c_count(k-1,i-1)%(10**9+7)))

### FIXED CODE ###

import math
def c_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
for i in range(1,k+1):
    if i <= n-k+1:
        print(((c_count(n-k+1,i)%(10**9+7)) * (c_count(k-1,i-1)%(10**9+7)))%(10**9+7))
    else:
        print(0)
n = int(input())
p=3.1415

print(2*n*p)

### FIXED CODE ###

n,m=map(int, input().split())
A = list(map(int, input().split()))
if n-sum(A)<0:
    print(-1)
    exit()

print(n-sum(A))
N = int(input())
A = [int(x) for x in input().split()]
A.sort()
was = []
def x(A,N):
    newA = []
    sw = True
    for i in range(N//2):
        if sw:
            was.append((A[i], A[-(i+1)]))
            newA.append(A[i] - A[-(i+1)])
        else:
            was.append((A[-(i+1)], A[i]))
            newA.append(A[-(i+1)] - A[i])
        sw = not sw
    if N%2 != 0:
        newA.append(A[N//2])
    if len(newA) == 2:
        was.append((max(newA), min(newA)))
        return max(newA) - min(newA)
    else:
        newA.sort()
        return x(newA, len(newA))

print(x(A,N))
for x,y in was:
    print(x, y)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
p = []
m = []
for a in A:
    if a < 0:
        m.append(a)
    else:
        p.append(a)
was = []
if N == 2:
    print(max(A)-min(A))
    print(max(A), min(A))
    quit()
if len(m) == 0:
    p.sort()
    m.append(p[0] - p[-1])
    was.append((p[0], p[-1]))
    p = p[1:-1]
elif len(p) == 0:
    m.sort()
    p.append(m[-1] - m[0])
    was.append((m[-1], m[0]))
    m = m[1:-1]

mm = m[0]
m = m[1:]
pp = p[0]
p = p[1:]
for x in p:
    was.append((mm,x))
    mm -= x
for x in m:
    was.append((pp,x))
    pp -= x
was.append((pp, mm))
print(pp-mm)
for p,m in was:
    print(p,m)
import bisect
import math

n,m = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort(reverse=True)

ans=[math.ceil(-a[0]/2)]
num = 0
now = 1

if n == 1:
    print(a[0] // 2**m)
    exit()

for i in range(m-1):
    #print(ans[0],a[now],now,ans)
    if ans[0] <= -a[now]:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
    else:
        ans.append(math.ceil(-a[now]/2))
        now += 1
#print(ans,ans,ans,ans)
print(-sum(ans)+sum(a[len(ans):]))
exit()
for i in range(1,n):
 if num >= m:
   break
 if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
   ans.append(-a[i]//2)
   num+=1
 else:
   pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
   ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える

print(ans)
print(-sum(ans))
exit()

a = [-a]
print(a)
exit()

tmp = a[0] // 2

del a[0]

idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print(a,idx)
exit()

if a[0] >= a[1]:
    a[0] = a[0] // 2
else:
    a[1] = a[1] // 2
    
print(a)

### FIXED CODE ###

import bisect
import math

n,m = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort(reverse=True)

ans=[math.ceil(-a[0]/2)]
num = 0
now = 1

if n == 1:
    print(a[0] // 2**m)
    exit()
    
for i in range(m-1):
    #print(ans[0],a[now],now,ans)
    if now >= n:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
        continue
    if ans[0] <= -a[now]:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
    else:
        ans.append(math.ceil(-a[now]/2))
        now += 1
#print(ans,ans,ans,ans)
        
if len(ans) == len(a):
    print(-sum(ans))
    exit()
        
print(-sum(ans)+sum(a[len(ans):]))
exit()
for i in range(1,n):
 if num >= m:
   break
 if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
   ans.append(-a[i]//2)
   num+=1
 else:
   pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
   ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える

print(ans)
print(-sum(ans))
exit()

a = [-a]
print(a)
exit()

tmp = a[0] // 2

del a[0]

idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print(a,idx)
exit()

if a[0] >= a[1]:
    a[0] = a[0] // 2
else:
    a[1] = a[1] // 2
    
print(a)
s=input()
  	z,o=0,0
    for i in range(len(s)):
      if s[i]=="0":
        z+=1
      else:
        o+=1
    print(2*min(z,o))

### FIXED CODE ###

s=input()
z,o=0,0
for i in range(len(s)):
  if s[i]=="0":
    z+=1
  else:
    o+=1
print(2*min(z,o))
a , b =int(),input().split()

if a <= b:
	for i in b:
    print(a*int(b))
 
else:
	for v in a:
	print(b*int(a))

### FIXED CODE ###

a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))
import math
n, m = input().split()
x = decimal(n)
y = decimal(m)
ans = math.floor(x*y)
print(ans)

### FIXED CODE ###

import math
from decimal import Decimal
n, m = input().split()
x = Decimal(n)
y = Decimal(m)
#print(n,m)
ans = math.floor(x*y)
print(ans)
import os, sys, re, math

(N, K) = [int(n) for n in input().split()]
P = [int(n) for n in input().split()]

def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp

exps = [get_exp_value(i) for i in range(200001)]

max_sum = sum(P[0:K])
max_pos = 0
for i in range(K, N):
    s = max_sum - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i - K

answer = 0
for i in range(max_pos, max_pos + K):
    answer += get_exp_value(P[i + 1])
    #answer += exps[P[i + 1]]

print(answer)


### FIXED CODE ###

import os, sys, re, math


def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp


(N, K) = [int(n) for n in input().split()]
P = [int(n) for n in input().split()]

exps = [get_exp_value(i) for i in range(200001)]

s = sum(P[0:K])
max_sum = 0
max_pos = 0
for i in range(K, N):
    s = s - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i

answer = 0
for i in range(max_pos - K, max_pos):
    answer += exps[P[i + 1]]

print(answer)
a = int(input())

b = int(input())


cross = int((a * b)/2)

if cross == 0:
    print("even")

if cross != 0:
    print("odd")


### FIXED CODE ###

a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')
N = int(input().strip())
array = [int(x) for x in input().split()]
for i in array:
  if i % 2 == 0:
    if i % 3 == 0 or i % 5 == 0:
      fg = True
    else:
      fg = False
      print('DENIED')
      break
if fg:
  print('APPROVED') 

### FIXED CODE ###

N = int(input())
array = [int(x) for x in input().split()]
fl=True
for i in array:
  if i % 2 == 0:
    if i % 3 != 0 and i % 5 != 0:
        fl = False
if fl: print('APPROVED')
else:print('DENIED')
n = int(input())
ans = [0 for i in range(1000)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            if (x*(x+y+z) + y*(y+z) + z*z) <= 1000:
                ans[(x*(x+y+z) + y*(y+z) + z*z)-1] += 1
for i in range(n):
    print(ans[i])

### FIXED CODE ###

n = int(input())
ans = [0 for i in range(10001)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            if x*x + y*y + z*z + x*y + x*z + y*z <= 10000:
                ans[x*x + y*y + z*z + x*y + x*z + y*z] += 1
            else:
              break
for i in range(1,n+1):
    print(ans[i])
X = input()
stack = []
for s in X:
  if not stack:
    stack.append(s)
  	continue
  if s == 'T' and stack[-1] == 'S':
    stack.pop()
  else:
    stack.append(s)
print(len(stack))

### FIXED CODE ###

def resolve():
    X = input()
    stack = []
    for s in X:
        if not stack:
            stack.append(s)
            continue
        if s == 'T' and stack[-1] == 'S':
            stack.pop()
        else:
            stack.append(s)
    print(len(stack))

resolve()
# B - Problem Set
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

dic = dict()

for di in d:
	if di in dic.keys():
		dic[di] += 1
	else:
		dic[di] = 1

for ti in t:
	if not ti in dic.keys():
		print('NO')
		sys.exit()
	elif dic[ti] < 1:
		print('NO')
		sys.exit()
	else:
		dic[ti] -= 1

print('YES')

### FIXED CODE ###

# B - Problem Set
def is_create(dic_d, t):
	for ti in t:
		if not ti in dic_d.keys():
			return False
		elif dic[ti] == 0:
			return False
		else:
			dic[ti] -= 1	
	
	return True


n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

dic = dict()

for di in d:
	if di in dic.keys():
		dic[di] += 1
	else:
		dic[di] = 1

if is_create(dic, t):
	print('YES')
else:
	print('NO')
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
link = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    link[a-1].append([b-1, c])
visited = [0] * N
ans = 0

#全ての頂点からループしてないか確かめるといけないかな？
def dfs(v, cnt):
    global ans
    if v == N-1:
        if visited[v] == 0:
            ans = cnt
        else:
            ans = max(ans, cnt)
        for p in link[v]:
            if visited[p[0]] and ans > 0:
                ans = 'inf'
                print(ans)
                exit()
            elif visited[p[0]] and ans <= 0:
                break
    visited[v] = 1
    for nv in link[v]:
        dfs(nv[0], cnt+nv[1])
    return

dfs(0, 0)
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
a = [0] * M
b = [0] * M
c = [0] * M
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    c[i] = -c[i]
    
INF = 10 ** 13
dist = [INF] * N

dist[0] = 0

for loop in range(N-1):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]

ans = dist[N-1]

nega = [0] * N

for loop in range(N):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]
            nega[b[i]-1] = 1
        if nega[a[i]-1] == 1:
            nega[b[i]-1] = 1

if nega[N-1]:
    print('inf')
else:
    print(-ans)
A,B,C=map(int,input().split)
d=B//A
if d<C:
  print(d)
else:
  print(C)

### FIXED CODE ###

A,B,C=map(int,input().split())
d=B//A
if d<C:
  print(d)
else:
  print(C)
count = 0
while true:
    count += 1
    n = int(input())
    if n == 0:
        break
    print('Case ' + str(count) + ' :' + str(n))

### FIXED CODE ###

count = 0
while 1:
    count += 1
    n = int(input())
    if n == 0:
        break
    print('Case ' + str(count) + ': ' + str(n))
A = [map(int, input().split())]
if sum(A) >= 22:
    print(bust)
else:
    print(win)

### FIXED CODE ###

A = [int(x) for x in input().split()]
if sum(A) >= 22:
    print("bust")
else:
    print("win")
from fractions import gcd

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

a.append(a[0])
neighbors_gcd = [gcd(a[i], a[i+1]) for i in range(n)]

print(sorted(neighbors_gcd)[2])

### FIXED CODE ###

from fractions import gcd

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

left = [0] * (n + 1)
for i in range(1, n):
    left[i] = gcd(left[i-1], a[i-1])

right = [0] * (n + 1)
for i in range(1, n):
    right[n-i] = gcd(right[n-i+1], a[n-i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i+1]))
print(ans)
a = [ input() for i in range(2)]
n = int(a[0])
s = a[0]
if n % 2 == 1:
  print("No")

if s[0:n/2] == s[n/2:]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

n = int(input())
s = input()
if n % 2 == 1:
  print("No")
else:
	if s[0:n//2] == s[n//2:]:
  		print("Yes")
	else:
  		print("No")
from collections import defaultdict
def solve():
    N = int(input())
    G = defaultdict(list)
    for i in range(N-1):
        u,v,w = map(int,input().split())
        u -= 1
        v -= 1
        G[u].append((v,w))
        G[v].append((u,w))

    res = [0] * N

    dfs(0,-1,1,G,res)

    print(*res, sep='\n')
def dfs(v,p,c,G,res):
    res[v] = c
    for e in G[v]:
        if e[0] == p:
            continue
        if e[1] % 2 == 0:
            dfs(e[0], v, 1-c,G,res)
        else:
            dfs(e[0],v,c,G,res)
        
if __name__ == '__main__':
    solve()

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**5)
def solve():
    N = int(input())
    G = defaultdict(list)
    for i in range(N-1):
        u,v,w = map(int,input().split())
        u -= 1
        v -= 1
        G[u].append((v,w))
        G[v].append((u,w))

    res = [0] * N

    dfs(0,-1,1,G,res)

    print(*res, sep='\n')
def dfs(v,p,c,G,res):
    res[v] = c
    for e in G[v]:
        if e[0] == p:
            continue
        if e[1] % 2 != 0:
            dfs(e[0], v, 1-c,G,res)
        else:
            dfs(e[0],v,c,G,res)
        
if __name__ == '__main__':
    solve()
n = int(input())
la = [int(w) for w in input().split()]

cnt = [0]*9
for a in la:
    cnt[a // 400] += 1

mi = len([_ for _ in cnt[:8] if _ > 0])
ma = mi+cnt[8]

print(mi, ma)


### FIXED CODE ###

n = int(input())
la = [int(w) for w in input().split()]

cnt = [0]*9
for a in la:
    if a > 3200:
        a = 3200
    cnt[a // 400] += 1

mi = len([_ for _ in cnt[:8] if _ > 0])
ma = mi+cnt[8]

if mi == 0:
    mi = 1

print(mi, ma)
# bit & 演算子は同じ位置のbitが１の時１を返す

def main():
    n, m = map(int, input().split())
    # ｋは何個のスイッチにつながっているか、ｓはスイッチの番号
    s = []; k = [] # s : どのスイッチとつながってるか、インデックスは電球を指す、　k: 電球が何個のスイッチとつながっているか
    for _ in range(m):
        tmp_k, *tmp_s = list(map(int, input().split()))
        k.append(tmp_k); s.append(tmp_s)
    p = list(map(int, input().split()))

    res = 0
    # スイッチの状態は２進数表記で表す。スイッチはｎ個あるので
    for bit in range(2**n):
        ok = True
        for i in range(m): # 各電球に対して見ていく
            cnt = 0
            for v in s[i]: # 各電球につながっているスイッチを見てる
                if ( bit & 1 << (v - 1) ): # bitの状態がスイッチvがついてる状態なのかどうか
            if cnt % 2 != p[i]:
                ok = False
        if ok: # okなら全ての電球が付いているということ
            res += 1

    print(res)



if __name__ == "__main__":
    main()

### FIXED CODE ###

#bit & 演算子は同じ位置のbitが１の時１を返す
def main():
    n, m = map(int, input().split())
    # ｋは何個のスイッチにつながっているか、ｓはスイッチの番号
    s = []; k = [] # s : どのスイッチとつながってるか、インデックスは電球を指す、　k: 電球が何個のスイッチとつながっているか
    for _ in range(m):
        tmp = list(map(int, input().split()))
        s.append(tmp[1:]); k.append(tmp[0])
    p = list(map(int, input().split()))

    res = 0
    # スイッチの状態は２進数表記で表す。スイッチはｎ個あるので
    for bit in range(2**n):
        ok = True
        for i in range(m): # 各電球に対して見ていく
            cnt = 0
            for v in s[i]: # 各電球につながっているスイッチを見てる
                if ( bit & 1 << (v - 1) ): # bitの状態がスイッチvがついてる状態なのかどうか
                    cnt += 1
            if cnt % 2 != p[i]:
                ok = False
        if ok: # okなら全ての電球が付いているということ
            res += 1

    print(res)

if __name__ == "__main__":
    main()
def main():
    h,w,k=map(int,input().split())
    s=[list(input()) for _ in range(h)]
    
    ans=[[0]*w for _ in range(h)]
    for idx in range(h):
        if '#' in s[idx]:
            i=idx
            break
            
    start,j,cnt,first,itigo=i,0,1,True,True
    while i<h:
        if s[i][j]=='#':
            if first:
                first=False
                itigo=False
                ans[i][j]=cnt
                j+=1
                continue
            cnt+=1
            ans[i][j]=cnt
        else:
            ans[i][j]=cnt

        j+=1
        if j==w:
            first=True
            if itigo:
                ans[i]=ans[i-1]
                i+=1
                j=0
                continue
            itigo=True
            i+=1
            j=0
            cnt+=1
    
    for i in range(start):
        ans[i]=ans[start]
    
    for i in range(h):
        print(*ans[i]) 
    
if __name__=='__main__':
    main()



### FIXED CODE ###

def main():
    h,w,k=map(int,input().split())
    s=[list(input()) for _ in range(h)]
    
    ans=[[0]*w for _ in range(h)]
    for idx in range(h):
        if '#' in s[idx]:
            i=idx
            break
            
    start,j,cnt,first=i,0,1,True

    while i<h:
        if j==w:
            if first:
                ans[i]=ans[i-1]
                i+=1
                j=0
                continue
            first=True
            i+=1
            j=0
            cnt+=1
            continue

        if s[i][j]=='#':
            if first:
                first=False
                ans[i][j]=cnt
                j+=1
                continue
            cnt+=1
            ans[i][j]=cnt
        else:
            ans[i][j]=cnt

        j+=1
    
    for i in range(start):
        ans[i]=ans[start]
    
    for i in range(h):
        print(*ans[i]) 
    
if __name__=='__main__':
    main()
a= map(int, input().split())
s = input()
if a <= 3200:
    print(s)
else:
    print('red')

### FIXED CODE ###

a= int(input())
s = input()
if 3200 <= a:
    print(s)
else:
    print('red')
x,n = map(int,input())
p = list(map(int,input.split()))
i = 0
ans = 0
while True:
  if(x-1 in p):
    if(x+1 in p):
      None
    else:
      ans = x+1
      break
  else:
    ans = x-1
    break
  i += 1
print(ans)
    
      

### FIXED CODE ###

x,n = map(int,input().split())
p = list(map(int,input().split()))
i = 0
ans = 0
while True:
  if(x-i in p):
    if(x+i in p):
      None
    else:
      ans = x+i
      break
  else:
    ans = x-i
    break
  i += 1
print(ans)
n = int(input())
ls = list(map(int, input().split()))
for i in range(0,n-1):
    for u in range(0, n-1):
        if ls(i) == ls(u):
            print("No")
else:
    print("Yes")

### FIXED CODE ###

import collections
n = int(input())
ls = list(map(int,input().split()))
if len(ls) == len(collections.Counter(ls)):
    print("YES")
else:
    print("NO")
N=int(input())
alpha=list("abcdefghijklmnopqrstuvwxyz")
k=26
l=1
while N-k>0:
  N-=k
  k*=26
  l+=1
ans=["a"]*l
N-=1
i=-1
while N>26:
  a=N%26
  N=N//26
  ans[i]=alpha[a]
  i-=1
ans[i]=alpha[N]
print("".join(ans))


### FIXED CODE ###

N=int(input())
alpha=list("abcdefghijklmnopqrstuvwxyz")
ans=""
while True:
  N-=1
  a=N%26
  N=N//26
  ans=alpha[a]+ans
  
  if N==0:
    break
print(ans)