Harryxun/stf_run huggingface dataset:
n = int(input())
F = []
for i in range(n):
  f = list(map(int,input().split()))
  shop = []
  for j in range(5):
    shop.append([f[2*j],f[2*j+1]])
  F.append(shop)
P = [list(map(int,input().split())) for _ in range(n)]

import numpy as np
ans = -float('inf')
for i in range(1,2**10):
  index =format(i,'b').zfill(10)
  open_j = [int(j) for j in index]
  open_j = np.array(open_j).reshape(5,2)
  score = 0
  for j in range(n):
    count = 0
    for k in range(5):
      for l in range(2):
        if F[j][k][l] and open_j[k][l]:
          count += 1
    score += P[j][count]
  ans = max(ans,score)
print(ans)

### FIXED CODE ###

n = int(input())         
import numpy as np

open = np.array([list(map(int,input().split())) for i in range(n)])
p  = np.array([list(map(int,input().split())) for i in range(n)])

max_p = -999999999999
                     
for j in range(1,2**10):  
  store = [0,0,0,0,0,0,0,0,0,0] 
  flag = True          
  for k in range(10):  
    if j %2 ==1 : 
      store[k] = 1 
    j = int(j/2)                           
#store = np.array([1,0,1,0,0,0,0,0,0,0]) 
  days = [sum(i) for i in store * open] 
  score = 0                            
  for i in range(n):                   
          score += p[i][days[i]]
  if score > max_p: 
    max_p = score            
print(max_p)
#include <stdio.h>

int main(){
    double a, b;
    long m;
    scanf("%lf %lf", &a, &b );
    m = a * b;
    printf("%ld\n", m);
    return 0;
}

### FIXED CODE ###

a, b = input().split()
a = int( a )
b = int( 1000 * float( b ) )
m = a * b
m = m // 1000

print( m )
A = list(map(int, input().split()))
if A == [5,7,5]
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, b, c = map(int, input().split())
if sorted((a, b, c)) == [5, 5, 7]:
  print('YES')
else:
  print('NO')
n,m = map(int,input().split())
a = []

for i in range(m):
    a.append(int(input()))

dp = [0] * (n+1)
dp[0] = 1

if 1 not in a:
    dp[1] = 1
    
for i in range(2,n+1):
    if i not in a:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 1000000007
        
print(dp[n])


### FIXED CODE ###

P , Q , R = map(int, input().split())

if P >= Q and P >= R:
    print(Q + R)
elif Q >= P and Q >= R:
    print(P + R)
else:
    print(P + Q)
num =int(input())
value = list(map(int, input().split()))
value.sort()
point = 0
for i in range (0, value[0]):
  cnt = 0
  for j in range(0, num):
    if value[j]%(value[0]-i)!=0:
      cnt += 1
      point = j
  if cnt == 1 or cnt == 0:
    break
print(value[0] - i)

### FIXED CODE ###

data = input().split()
A = int(data[0])
B = int(data[1])
T = int(data[2]) + 0.5
biscuit = 0
time = A
while time < T:
  biscuit += B
  time += A

print(biscuit)
n=raw_input()
if n[0]=n[1]=n[2]=n[3] or n[0]=n[1]=n[2]!=n[3] or n[1]=n[2]=n[3]!=n[0]:
  print "Yes"
else:
  print "No"

### FIXED CODE ###

n=raw_input()
if n[0]==n[1]==n[2]==n[3] or n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
  print "Yes"
else:
  print "No"
a=sorted(list(map(int,input().split())))
print(a*b//2)

### FIXED CODE ###

a=sorted(list(map(int,input().split())))
print(a[0]*a[1]//2)
import collections
from collections import defaultdict
import numpy as np

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

A = np.array(A,dtype='int64')
C = np.append([0],np.cumsum(A))
#累積和を算出して最初に０をつける。
L = [i%M for i in C]
#Ｍで割ったあまりを求めてリスト化
d = defaultdict(int)
for i in L:
    d[i] +=1
#各余りに対して、その数が何個あるかを求める。

ans = 0
for i in d.values():
    S = i * (i-1) / 2
    ans+=S
    
print(int(ans))

### FIXED CODE ###

A,B = list(map(int,input().split()))
print(1) if A%B!=0 else print(0)
s=list(input())
K=int(input())
for i in range(len(s)-1):
    if s[i]!="a"
        a= ord("z")+1 - ord(s[i])
        if K>=a:
            s[i]="a"
            K-=a
if K:
    s[-1]=chr((K+ord(s[-1])-ord("a"))%(ord("z") - ord("a")+1)+ord("a"))
print("".join(s))


### FIXED CODE ###

s=list(input())
K=int(input())
for i in range(len(s)-1):
    if s[i]!="a":
        a= ord("z")+1 - ord(s[i])
        if K>=a:
            s[i]="a"
            K-=a
if K:
    s[-1]=chr((K+ord(s[-1])-ord("a"))%(ord("z") - ord("a")+1)+ord("a"))
print("".join(s))
import math
import numpy as np
H,N=map(int,input().split)
A=[]
B=[]
for i in range(N):
    n,a=input().split()
    A.append(int(n))
    B.append(int(a))
C=[]
for i in range(N):
  C.append(A[i]/B[i])
sub=0
for i in range(N):
  if C[i]>=C[sub]:
    sub=i
sub2=math.ceil(H/A[sub])
sub3=sub2*B[sub]
for ia in range(H,sub2):
  t = ia
  M = len(A) - 1
  elm = []
  for i, step in enumerate(A):
    temp = [1] * (M - i)
    elm.append(np.arange(0, t+1, step).reshape(-1, *temp))
  res = 0
  for x in elm:
    res = res + x
  sub4=0
  for x in np.argwhere(res == t):
    for ib in range(N):
    sub4+=B[ib]*x[ib]
  if sub4<=sub3:
    sub3=sub4
print(sub3)

### FIXED CODE ###

H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
    n,a=input().split()
    A.append(int(n))
    B.append(int(a))
def f(x):
    if x<=0:
        return 0
    else:
        mini=g(x-A[0])+B[0]
        for i in range (1,N):
            sub=g(x-A[i])+B[i]
            if sub<mini:
                mini=sub
        return mini
def g(x):
    if x<0:
        return 0
    else:
        return g_list[x]
g_list=[]
g_list.append(0)
for i in range(1,H+1):
    g_list.append(f(i))
print(g_list[-1])
import math
N,K = map(int,input().split())
Ans = (math.log(K,N) +1)
print(Ans)

### FIXED CODE ###

import math
N,K = map(int,input().split())
Ans = (int(math.log(N,K)) +1)
print(Ans)
N = int(input())
K = int(input())
ans = [1]*N

for i in range(0,K):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(0,N):
    if table.count(j) != 0:
      ans[j] = 0
print(sum(ans))

### FIXED CODE ###

NK = list(map(int, input().split()))
ans = [0]*NK[0]

for i in range(0,NK[1]):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(1,NK[0]+1):
    if table.count(j) != 0:
      ans[j-1] = 1
print(NK[0]-sum(ans))
N,K,X,Y=[int(input()) i in range(4)]
print(X*N+Y*max(0,N-K))

### FIXED CODE ###

N,K,X,Y=[int(input()) for i in range(4)]
print(N*X-(X-Y)*max(0,N-K))
n, k = map(int, input().split())
print(k * pow(k-1, n-1))

### FIXED CODE ###

li = set(map(int, input().split()))
print(len(li))
W, H, w, y, r = map(int, input().split())

if (x- r) >= 0 and (x + r) <= W:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

w, h, x, y, r = map(int, input().split())

if x + r <= w and y + r >= 0 and x - r >= 0 and y + r <= h:
    print("Yes")
else:
    print("No")
import sys
import numpy as np

def get_cum_gcd(N, As):
    cum_gcd = [0] * N
    for i, n in enumerate(As):
        if i == 0:
            cum_gcd[i] = n
        else:
            cum_gcd[i] = np.gcd(cum_gcd[i-1], n)
    return cum_gcd

def get_cav_gcds(N, cum_l, cum_r):
    cav_gcds = [0] * N
    for i in range(N):
        if i == 0:
            cav_gcds[i] = cum_r[i+1]
        elif i == N-1:
            cav_gcds[i] = cum_l[i-1]
        else:
            cav_gcds[i] = np.gcd(cum_l[i-1], cum_r[i+1])
    return cav_gcds

def main():
    input = sys.stdin.readline
    N = int(input())
    As = list(map(int, input().split()))
    cum_l = get_cum_gcd(N, As)
    cum_r = list(reversed(get_cum_gcd(N, reversed(As))))
    cav_gcds = get_cav_gcds(N, cum_l, cum_r)
    print(max(cav_gcds))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def gcd(a, b):
    b, a = sorted([a, b])
    if a%b == 0:
        return b
    else:
        return gcd(b, a%b)

def get_cum_gcd(N, As):
    cum_gcd = [0] * N
    for i, n in enumerate(As):
        if i == 0:
            cum_gcd[i] = n
        else:
            cum_gcd[i] = gcd(cum_gcd[i-1], n)
    return cum_gcd

def get_cav_gcds(N, cum_l, cum_r):
    cav_gcds = [0] * N
    for i in range(N):
        if i == 0:
            cav_gcds[i] = cum_r[i+1]
        elif i == N-1:
            cav_gcds[i] = cum_l[i-1]
        else:
            cav_gcds[i] = gcd(cum_l[i-1], cum_r[i+1])
    return cav_gcds

def main():
    input = sys.stdin.readline
    N = int(input())
    As = list(map(int, input().split()))
    cum_l = get_cum_gcd(N, As)
    cum_r = list(reversed(get_cum_gcd(N, reversed(As))))
    cav_gcds = get_cav_gcds(N, cum_l, cum_r)
    print(max(cav_gcds))

if __name__ == '__main__':
    main()
n,m=map(int,input().split())
r=list(map(int,input().split()))
c=list(map(int,input().split()))
r.sort(reverse=True)
c.sort(reverse=True)
dict1={}
dict2={}
for i in range(n):
    dict1.setdefault(r[i],0)
    dict1[r[i]]+=1
for i in range(m):
    dict2.setdefault(c[i],0)
    dict2[c[i]]+=1
x,y=0,0
ans=1
if dict1.get(n*m)*dict2.get(n*m)>1:
    print(0)
    exit()
for i in range(n*m,0,-1):
    table=x*y
    ex=table-(n*m-i)
    dy=dict1.get(i,0)
    dx=dict2.get(i,0)
    print(ans,x,y)
    x+=dx
    y+=dy
    if dx*dy==1:
        ans*=1
    elif dx==0 and dy==1:
        ans*=x
    elif dy==0 and dx==1:
        ans*=y
    else:
        ans*=(x*y-(n*m-i))
print(ans%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
r=list(map(int,input().split()))
c=list(map(int,input().split()))
r.sort(reverse=True)
c.sort(reverse=True)
dict1={}
dict2={}
for i in range(n):
    dict1.setdefault(r[i],0)
    dict1[r[i]]+=1
for i in range(m):
    dict2.setdefault(c[i],0)
    dict2[c[i]]+=1
x,y=0,0
ans=1
mod=10**9+7
for i in range(n*m,0,-1):
    dy=dict1.get(i,0)
    dx=dict2.get(i,0)
    if dx*dy==1:
        x+=1
        y+=1
    elif dx==0 and dy==1:
        ans*=x
        y+=1
    elif dy==0 and dx==1:
        ans*=y
        x+=1
    else:
        ans*=(x*y-(n*m-i))
        ans%=mod
print(ans%mod)
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
    
ns = defaultdict(set)
for _ in range(n-1):
    u,v = [int(c) for c in input().split()]
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)

from bisect import bisect_left
 
l = [a[0]]
# for a in A[1:]:
#     if a > L[-1]:
#         # Lの末尾よりaが大きければ増加部分列を延長できる
#         L.append(a)
#     else:
#         # そうでなければ、「aより小さい最大要素の次」をaにする
#         # 該当位置は、二分探索で特定できる
#         L[bisect_left(L, a)] = a
# return len(L)

ans = [None] * n

def sub(u, prev, lst, old, ind, ans):
    aa = a[u]
    if aa > lst[-1]:
        lst.append(aa)
        old = -1
        ind = None
    else:
        ind = bisect_left(lst, aa)
        old = lst[ind]
        lst[ind] = aa
    ans[u] = len(lst)
#     print(lst)
    for v in ns[u]:
        if prev==v:
            continue
        sub(v, u, lst, old, ind, ans)
    if old==-1:
        lst.pop()
    elif old is not None:
        lst[ind] = old


sub(0, -1, [a[0]], None, None, ans)
print("\n".join(map(str, ans)))


### FIXED CODE ###


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

import sys
sys.setrecursionlimit(max(1000, 2*n))


ns = defaultdict(set)
for _ in range(n-1):
    u,v = [int(c) for c in input().split()]
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)

from bisect import bisect_left
 
l = [a[0]]
# for a in A[1:]:
#     if a > L[-1]:
#         # Lの末尾よりaが大きければ増加部分列を延長できる
#         L.append(a)
#     else:
#         # そうでなければ、「aより小さい最大要素の次」をaにする
#         # 該当位置は、二分探索で特定できる
#         L[bisect_left(L, a)] = a
# return len(L)

ans = [None] * n

def sub(u, prev, lst, old, ind, ans):
    aa = a[u]
    if len(lst)==0 or aa > lst[-1]:
        lst.append(aa)
        old = -1
        ind = None
    else:
        ind = bisect_left(lst, aa)
        old = lst[ind]
        lst[ind] = aa
    ans[u] = len(lst)
#     print(lst)
    for v in ns[u]:
        if prev==v:
            continue
        sub(v, u, lst, old, ind, ans)
    if old==-1:
        lst.pop()
    elif old is not None:
        lst[ind] = old

lst = []
sub(0, -1, lst, None, None, ans)
print("\n".join(map(str, ans)))
x = int(input())
y = int(input())
print(x*y,2*(x+y))

### FIXED CODE ###

x, y = map(int,input().split(" "))
print(x*y, 2*(x+y))
import collections
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
for v in range(n):
  q=collections.deque()
  q.append((v,1))
  checked=[0]*n
  anss=[]
  while len(q)!=0:
    tmp,depth=q.popleft()
    anss.append(depth)
    checked[tmp]=1
    for v in g[tmp]:
      if checked[v]==0:
        q.append((v,depth+1))
  ans=max(ans,max(anss))
print(ans)

### FIXED CODE ###

from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)
g2=[[0]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    g2[i][j]=int(arr[i][j])

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
d=floyd_warshall(g2)
for i in range(n):
  ans=max(ans,int(max(d[i])+1))
print(ans)
n, k = [int(i) for i in input().split(" ")]
t = []
d = []

for i in range(0, n):
    x, y = [int(i) for i in input().split(" ")]
    t.append(x)
    d.append(y)
    
dt = zip(d, t)
dt = sorted(dt, key = lambda k:k[0], reverse=True)
td = [[] for i in range(0, n + 1)]
tp = []
dp = [[0 for j in range(0, k)] for i in range(0, k)]
eaten = [[0 for j in range(0, k)] for i in range(0, k)]

for i in range(0, n):
    td[dt[i][1]].append(dt[i][0])
    if len(td[dt[i][1]]) == 1:
        tp.append(dt[i][1])

dp[0][0] = td[tp[0]][0] + 1
eaten[0][0] = 1

for j in range(1, k):
    if eaten[0][j - 1] < len(td[tp[0]]):
        dp[0][j] = dp[0][j - 1] + td[tp[0]][eaten[0][j - 1]]
        eaten[0][j] = eaten[0][j - 1] + 1
    else:
        break


for i in range(1, k):
    eaten[i][i] = 1
    dp[i][i] =  dp[i - 1][i - 1] + td[tp[i]][0] + 2 * i + 1
    for j in range(i + 1, k):
        if dp[i - 1][j - 1] == 0 or (eaten[i][j - 1] < len(td[tp[i]]) and 2 * i + 1 + td[tp[i]][0] < td[tp[i]][eaten[i][j - 1]]):
            if eaten[i][j - 1] < len(td[tp[i]]) and dp[i][j - 1] > 0:
                dp[i][j] = dp[i][j - 1] + td[tp[i]][eaten[i][j - 1]]
                eaten[i][j] = eaten[i][j - 1] + 1
        else:
            if dp[i - 1][j - 1] > 0:
                dp[i][j] = dp[i - 1][j - 1] + 2 * i + 1 + td[tp[i]][0]
                eaten[i][j] = 1

print(max([i[-1] for i in dp]))

### FIXED CODE ###

n, k = [int(i) for i in input().split(" ")]
t = []
d = []

for i in range(0, n):
    x, y = [int(i) for i in input().split(" ")]
    t.append(x)
    d.append(y)

dt = zip(d, t)
dt = sorted(dt, key = lambda k:k[0], reverse=True)
t_max = [False for i in range(0, n + 1)]
d_max = []
d_non_max = []

for i in range(0, n):
    if t_max[dt[i][1]]:
        d_non_max.append(dt[i][0])
    else:
        t_max[dt[i][1]] = True
        d_max.append(dt[i][0])
        
p = [0 for i in range(0, len(d_max) + 1)]
sum_max = 0
sum_non_max = sum(d_non_max[0:min(len(d_non_max), k)])

for i in range(1, len(p)):
    sum_max += d_max[i - 1]
    if k - i >= 0 and k - i < len(d_non_max):
        sum_non_max -= d_non_max[k - i]
    if k - i >= 0 and k - i - 1 < len(d_non_max):
        p[i] = sum_max + sum_non_max + i * i
    else:
        p[i] = 0
        
print(max(p))
s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(Input()))]

print(max([s.count(s[i]) - t.count(s[i]) for i in range(len(S))]))

### FIXED CODE ###

s = [input() for _ in range(int(input()))]
t = [input() for _ in range(int(input()))]

print(max(0,max(s.count(s[i]) - t.count(s[i]) for i in range(len(s)))))
def calc():
    d = a
    a = b
    b = d

    d = a
    a = c
    c = d

    mytuple = (a,b,c)
    return mytuple

a, b, c = map(int, input().split())
ans = calc()
print(*ans)

### FIXED CODE ###

def calc():
    x, y, z = c, a, b

    print(x, y, z)

a, b, c = map(int, input().split())
calc()
def g():
    from collections import defaultdict
    N, M = map(int, input().split())
    xy = defaultdict(list)
    for _ in range(M):
        x, y = map(int, input().split())
        xy[x].append(y)
    memo = {}

    def g2(x):
        if x in memo:
            return memo[x]
        else:
            r = 0
            for ny in xy[x]:
                r = max(r, g2(ny) + 1)
            memo[x] = r
        return r

    ans = [g2(i) for i in range(1, N + 1)]
    return max(ans)


if __name__ == '__main__':
    ans = g()
    print(ans)

### FIXED CODE ###

def g():
    from collections import defaultdict
    import sys

    sys.setrecursionlimit(10 ** 6)
    N, M = map(int, input().split())
    xy = defaultdict(list)
    memo = {}
    for _ in range(M):
        x, y = map(int, input().split())
        xy[x].append(y)

    def g2(x):
        if x in memo:
            return memo[x]
        else:
            r = 0
            for ny in xy[x]:
                r = max(r, g2(ny) + 1)
            memo[x] = r
        return r

    ans = 0
    for i in range(1, N + 1):
        ans = max(ans, g2(i))
    return ans


if __name__ == '__main__':
    ans = g()
    print(ans)
a, b, c = map(int, input().split())
if a < b:
 if b < c:
  print "yes"
elif:
 print "no"

### FIXED CODE ###

a, b, c = map(int, raw_input().split())
if a < b and b < c:
 print "Yes"
else:
 print "No"
import sys
inputs = sys.stdin.readlines()

from collections import Counter

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

def check(N, a_list):
    mc = Counter(a_list).most_common()
    n = len(mc)
    if n == 1:
        if mc[0][0] == 0:
            print('Yes')
            return
    elif n == 2:
        if mc[0][1] == 2*N // 3 and most_common[1][0] == 0:
            print('Yes')
            return
    elif n == 3:
        if mc[0][1] == mc[1][1] == mc[2][1] and mc[0][0] ^ mc[1][0] ^ mc[2][0] == 0:
            print('Yes')
            return
    print('No')

check(N, a_list)

### FIXED CODE ###

import sys
inputs = sys.stdin.readlines()

N = int(inputs[0])
a_list = list(map(int, inputs[1].split()))

from collections import Counter

def all_zeros(a_list):
    return sum(a_list) == 0

def check(N, a_list):
    if all_zeros(a_list):
        print('Yes')
        return
    elif N % 3 == 0:
        x = N // 3
        if not all([v % x == 0 for v in Counter(a_list).values()]):
            print('No')
            return
        while not all_zeros(a_list):
            counter = Counter([a & 1 for a in a_list])
            if counter[0] == x or counter[0] == N:
                a_list = [a >> 1 for a in a_list]
            else:
                print('No')
                return
        print('Yes')
    else:
        print('No')

check(N, a_list)
import itertools
n, m, q = map(int, input().split())
A = itertools.product(range(1, m + 1), repeat=m)
quads = [[int(i) for i in input().split()] for j in range(q)]
max_p = 0
for a in A:
    p = 0
    for quad in quads:
        if a[quad[1] - 1] - a[quad[0] - 1] == quad[2]:
            p += quad[3]
    if max_p < p:
        max_p = p
print(max_p)

### FIXED CODE ###

import itertools
n, m, q = map(int, input().split())
A = itertools.combinations_with_replacement(range(1, m+1), n)
quads = [[int(i) for i in input().split()] for j in range(q)]
max_p = 0
for a in A:
    p = 0
    for quad in quads:
        if a[quad[1] - 1] - a[quad[0] - 1] == quad[2]:
            p += quad[3]
    if max_p < p:
        max_p = p
print(max_p)
l=list(map(int,input().split()))
d=list(map(int,input().split()))
d_bar=[]
for m in range(10):
    if m not in d:
        d_bar.append(m) 
d_bar.sort()
n=[int(k) for k in str(l[0])

for i in range(len(n))
    dig1=0
    dig2=0
    for j in range(l[1]):
        p=dig1+d_bar[j]*10**(range(l[0])-i)
        if p>l[0]:
            break
        dig1=p
        dig2=dig2+d_bar[j]*l[1]**(range(l[0])-i)
dig2=dig2+1
r=dig
R=[]
while q!=0 or q!=1:
    q=q/l[1]
    r=q%l[1]
    R.append(r)
s=int(sum[str(-t-1) for t in R])
print(s)




### FIXED CODE ###

l=list(map(int,input().split()))
d=list(map(int,input().split()))
u={i for i in range(10)}
d_bar=u-set(d)
d_bar={str(i) for i in d_bar}
n=l[0]
n_set=set(str(n))
while True:
    if n_set<=d_bar:
        print(n)
        break
    n=n+1
    n_set=set(str(n))
import fractions

N = int(input())
inp_ints = list(map(int, input().split()))
ints = list(set(inp_ints))
""" uniq_ints = list(set(inp_ints))

ints = uniq_ints
for m in uniq_ints:
    if inp_ints.count(m) >= 2:
        ints.append(m) """

gcd = 0
result = 1
holed_ints = []
for i in range(len(ints)):
    holed_ints = ints[:i] + ints[i+1:]
    gcd = 0
    for j in range(len(ints)-1):
        gcd = fractions.gcd(gcd, holed_ints[j])
    if gcd > result:
        result = gcd

print(result)

### FIXED CODE ###

A, B, T = map(int, input().split())
result = T // A * B

print(result)
from scipy.special import perm, comb

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


for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1, exact=True)*comb(n-k+1, i, exact=True)%(10**9+7))

### FIXED CODE ###

import math

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

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

for i in range(1, k+1):
    if n-k < i-1:
        print(0)
    else:
        print(comb(k-1, i-1)*comb(n-k+1, i)%(10**9+7))
N, K = map(int,input().split())
x = list(map(int,input().split()))

o = 0
if x[N-1] <= 0:
	print(x[N-K])
	exit()
if x[0] >= 0:
	print(x[K-1])
	exit()
if 0 in x:
	i = x.index(0)
	del x[i]
	N,K = N-1,K=1

while x[o] < 0:
	o += 1
	if o == N-1:
		break

MIN = float("inf")
for i in range(-K-1,K+1,1):
	l = o - i+1
	r = o + K-i
	if not(l < 0 or l >= N or r < 0 or r >= N):
		cur1 = 2* abs(x[l]) + abs(x[r])
#		print([l,r,cur1,cur2])
		if cur1 < MIN:
			MIN = cur1
		if cur2 < MIN:
			MIN = cur2
print(MIN)





### FIXED CODE ###

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

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K - 1
	cur1 = abs(x[l]) + abs(x[r]-x[l])
	cur2 = abs(x[r]) + abs(x[r]-x[l])
#	print([l,r,cur1,cur2])
	if cur1 < MIN:
		MIN = cur1
	if cur2 < MIN:
		MIN = cur2
print(MIN)
n = int(input())
M = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    temp = list(map(int, input().split()))
    for i in range(temp[1]):
        M[temp[0]-1][temp[i+2]-1] = 1

WHITE = 0
GRAY = 1
BLACK = 2
color, d, f = [WHITE for i in range(n)]
t = 1

def visit(u):
    color[u] = GRAY
    d[u] += t
    t += 1
    for v in range(n):
        if (M[u-1][v-1] == 0):
            continue
        if (color[v] == WHITE):
            visit(v)
    color[u] = BLACK
    f[u] = t
    t += 1

for u in range(n):
    if (color[u] == WHITE):
        visit(u)
for u in range(n):
    print(str(u+1), str(d[u]), str(f[u]), sep = " ")

### FIXED CODE ###

def dfs(u):
    global dfs_color, d, f, t
    color[u] = GRAY
    d[u] += t
    t += 1
    for v in range(n):
        if (M[u][v] == 0):
            continue
        else:
            if (color[v] == WHITE):
               dfs(v)
    color[u] = BLACK
    f[u] = t
    t += 1

n = int(input())
M = [[False for i in range(n)] for j in range(n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    for j in range(tmp[1]):
        M[tmp[0]-1][tmp[j+2]-1] = True

WHITE = 0
GRAY = 1
BLACK = 2
color = [WHITE for i in range(n)]
d = [0 for i in range(n)]
f = [0 for i in range(n)]
t = 1

for u in range(n):
    if (color[u] == WHITE):
        dfs(u)
for u in range(n):
    print(str(u+1), str(d[u]), str(f[u]), sep = " ")