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

n=int(input())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
f=list(map(int,input().split()))
g=list(map(int,input().split()))
ans=[n*[0]for _ in range(n)]
for b in range(64):
  u=[(a&1<<b)//(1<<b)for a in f]
  v=[(a&1<<b)//(1<<b)for a in g]
  q=[[(u[i]&v[j])|((s[i]^1)*u[i])|((t[j]^1)*v[j])for j in range(n)]for i in range(n)]
  l=[sum(q[i])for i in range(n)]
  m=[sum(k[j]for k in q)for j in range(n)]
  for i in range(n):
    if s[i]*u[i]*(l[i]==0):
      for j in range(n):
        if(t[j]^1)*(n-m[j]>1):q[i][j]=u[i];m[j]+=1;break
  for j in range(n):
    if t[j]*v[j]*(m[j]==0):
      for i in range(n):
        if(s[i]^1)*(n-l[i]>1):q[i][j]=v[j];l[i]+=1;break
  h=q[0][:]
  w=[i[0]for i in q]
  for i in range(n):
    for j in range(n):
      if s[i]:w[i]|=q[i][j]
      else:w[i]&=q[i][j]
      if t[j]:h[j]|=q[i][j]
      else:h[j]&=q[i][j]
      ans[i][j]|=q[i][j]<<b
  if(v!=h)|(u!=w):print(-1);exit() 
for i in ans:print(*i)

### FIXED CODE ###

n=int(input())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
v=list(map(int,input().split()))
ans=[n*[0]for _ in range(n)]
ss=[u[i]if s[i]==0 else 0 for i in range(n)]
tt=[v[i]if t[i]==0 else 0 for i in range(n)]
son=[[]for _ in range(n)]
ton=[[]for _ in range(n)]
sno=[[n-1]*64 for _ in range(n)]
tno=[[n-1]*64 for _ in range(n)]
for i in range(n):
  for j in range(n):
    ans[i][j]=u[i]&v[j]
    if s[i]==0:
      ans[i][j]|=u[i]
      ss[i]&=ans[i][j]
    else:
      ss[i]|=ans[i][j]
    if t[j]==0:
      ans[i][j]|=v[j]
      tt[j]&=ans[i][j]
    else:
      tt[j]|=ans[i][j]
    if s[i]==0 or t[i]==0:
      for k in range(64):
        if ans[i][j]&1<<k:
          if s[i]==0:sno[i][k]-=1
          if t[j]==0:tno[j][k]-=1
    if j==n-1:
      if s[i]==1:
        if ss[i]|u[i]>u[i]:print(-1);exit()
        if ss[i]!=u[i]:
          for k in range(64):
            if u[i]&1<<k:
              if (ss[i]&1<<k)==0:
                son[i].append(k)
          ss[i]=1
        else:ss[i]=0
      else:
        if ss[i]!=u[i]:print(-1);exit()
        else:ss[i]=2
    if i==n-1:
      if t[j]==1:
        if tt[j]|v[j]>v[j]:print(-1);exit()
        if tt[j]!=v[j]:
          for k in range(64):
            if v[j]&1<<k:
              if (tt[j]&1<<k)==0:
                ton[j].append(k)
          tt[j]=1
        else:tt[j]=0
      else:
        if tt[j]!=v[j]:print(-1);exit()
        else:tt[j]=2
for i in range(n):
  for k in son[i]:
    for j in range(n):
      if t[j]==0:
        if tno[j][k]>0:
          ans[i][j]|=1<<k
          tno[j][k]-=1
          break
      if j==n-1:print(-1);exit()
for j in range(n):
  for k in ton[j]:
    for i in range(n):
      if s[i]==0:
        if sno[i][k]>0:
          ans[i][j]|=1<<k
          sno[i][k]-=1
          break
      if i==n-1:print(-1);exit()
for i in range(n):
  if s[i]==0:uu=ans[i][0]
  else:uu=0
  for j in range(n):
    if s[i]==0:uu&=ans[i][j]
    else:uu|=ans[i][j]
  if uu!=u[i]:print(-1);exit()
for j in range(n):
  if t[j]==0:vv=ans[0][j]
  else:vv=0
  for i in range(n):
    if t[j]==0:vv&=ans[i][j]
    else:vv|=ans[i][j]
  if vv!=v[j]:print(-1);exit()
for i in ans:print(*i)
### BUGGY CODE ###

D=60
f=lambda:[*map(int,input().split())]
n,k=f()
l=f()
t=[[0]*n for _ in range(D)]
for i in range(n):
  t[0][i]=l[i]-1
for i in range(D-1):
  for j in range(n):
    t[i+1][j]=t[i][t[i][j]]
a=0
for i in range(D):
  if k%2: a=t[i][a]
  k//=2
print(a+1)

### FIXED CODE ###

f=lambda:map(int,input().split())
n,k=f()
a=list(f())
lv=[-1]*n
lv[0]=0
p=0
for i in range(n):
  t=a[p]-1
  if lv[t]>=0:
    l,r=lv[t],i+1
    break
  lv[t]=i+1
  p=t
print(lv.index(l+(k-l)%(r-l) if k>l else k)+1)
### BUGGY CODE ###

# C - Reconciled?
N, M = map(int,input().split())

S = 1
for i in range(1,min(N,M)+1):
    S *= i

ans = 0
if abs(N-M) > 1:
    ans = 0
elif abs(N-M) == 1:
    ans = S*S*max(N,M)
else:
    ans = S*S*2

ans = ans % 1000000007

print(ans)


### FIXED CODE ###

# C - Reconciled?
import math
N, M = map(int,input().split())

S = math.factorial(min(N,M)) % 1000000007

ans = 0
if abs(N-M) > 1:
    ans = 0
elif abs(N-M) == 1:
    ans = S*S*max(N,M)
else:
    ans = S*S*2

ans = ans % 1000000007

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

def binary(x):
    '''40桁の2進数表記の作成'''

    k = 40
    s = ''
    for i in reversed(range(k)):
        s += str(x // 2 ** i)
        x %= 2 ** i

    return s

def decimal(s):
    '''40桁の2進数を10進数に変換'''

    k = 40
    x = 0
    for i in range(k):
        x += int(s[i]) * 2 ** (k - 1 - i) 

    return x

def xor(x, y):
    '''xor calcuration'''

    bx = binary(x)
    by = binary(y)
    s = ''

    for i in range(len(bx)):
        if abs(int(bx[i]) - int(by[i])):
            s += '1'
        else:
            s += '0'
    return decimal(s)

def f(x, a):
    '''f(x) calcuration'''

    fx = 0
    for i in a:
        fx += xor(x, i)

    return fx


n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]


fx = []
for x in range(k + 1):
    fx.append(f(x, a))

print(max(fx))


### FIXED CODE ###

# bit演算という方法がある、ビット演算子
# a & b 1,1で1
# a | b 1,1, 1,0, 0,1で1
# a ^ b xor
# ~a ビット反転
# << 左シフト
# >> 右シフト
# 未知のxkを既知のkkに置き換える
# k += 1 として、x < k を満たす
# この時、xの未知の40桁のいくつかを、既知のkで置き換える
# 注意として、xはkより大きくなってはいけない

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

ck = [0 for i in range(40)]
for i in a:
    for j in range(40):
        if i>>j & 1:
            ck[j] += 1

fx = []
for i in range(40):

    if (k+1)>>i & 1 == 0:
        continue

    ans = 0
    for j in range(40):
        if j > i:
            if ((k+1)>>j) & 1:
                ans += (1<<j) * (n-ck[j])
            else:
                ans += (1<<j) * ck[j]
        elif j == i:
            ans += (1<<j) * ck[j]
        else:
            if ck[j] * 2 > n:
                ans += (1<<j) * ck[j]
            else:
                ans += (1<<j) * (n-ck[j])

    fx.append(ans)

print(max(fx))
### BUGGY CODE ###

H, W = map(int, input().split())

List = list(range(H) for i in range(W))
count = 0

for i in range(W):
  for j in range(H):
    if List[i][j]%2 == 0 and i%2 ==0 or List[i][j]%2 == 1 and i%2 ==1:
      count +=1

print(count)


### FIXED CODE ###

H, W = map(int, input().split())

if H==1 or W==1:
  Answer =1

elif W%2 ==0:
  Answer = W/2*H
  
else:
  count = (W-1)/2 +1
  if H%2 ==0:
    Answer = count*H - H/2
  else:
    Answer = count*H - (H-1)/2

print(int(Answer))
### BUGGY CODE ###

import itertools
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N = int(input())

matr = [tuple(map(int, input().split())) for _ in range(N)]
way = floyd_warshall(matr).astype(int)
if np.any(way < matr):
    print(-1)
    exit()

way.tolist()
ans = 0
for a, b in itertools.combinations(range(N), 2):
    for c in range(N):
        if c == a or c == b:
            continue
        if matr[a][b] == matr[a][c] + matr[c][b]:
            break
    else:
        ans += matr[a][b]
print(ans)


### FIXED CODE ###

import itertools
import numpy as np
from scipy.sparse.csgraph import floyd_warshall


def main():
    N = int(input())
    matr = np.array([tuple(map(int, input().split())) for _ in range(N)], dtype=np.int64)
    way = floyd_warshall(matr).astype(int)
    if np.any(way < matr):
        print(-1)
        exit()

    ans = 0
    for a, b in itertools.combinations(range(N), 2):
        eq = (matr[a, b] == (matr[a] + matr[:, b]))
        eq[a] = eq[b] = False
        if not np.any(eq):
            ans += matr[a, b]
    print(ans)


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

def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    ans = 1
    for i in range(1, P[0]):
        if i < min(P[:P.index(i)]):
            ans += 1
    print(ans)
resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    min = P[0]
    ans = 1
    for i in P:
        if i < min:
            min = i
            ans += 1
    print(ans)
resolve()
### BUGGY CODE ###

import numpy as np
import sys
def input(): return sys.stdin.readline()

n=int(input())
a=np.array(list(map(int,input().split())))
 
ans=0
#print(a%(np.array([a for _ in range(n)])).transpose())
 
for i in range(n):
  b=a[i]%a==0
  #print(b)
  if np.count_nonzero(b)==1:
    ans+=1
print(ans)


### FIXED CODE ###

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

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6+2)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6+2:
    cnt[x]+=1
    x+=a
for a in A:
  #print(cnt[a])
  if cnt[a]==1:
    ans+=1
print(ans)
### BUGGY CODE ###

#dp[i][j][k]=(i,j)にアイテムをk個以下使って移動するときの最大値
#入力
r,c,k=list(map(int,input().split()))

rck=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(k):
     r_num,c_num,k_num=list(map(int,input().split()))
     rck[r_num][c_num]=k_num

#dpテーブルと初期条件
dp_0=[[0 for j in range(c+1)] for k in range(r+1)]
dp_1=[[0 for j in range(c+1)] for k in range(r+1)]
dp_2=[[0 for j in range(c+1)] for k in range(r+1)]
dp_3=[[0 for j in range(c+1)] for k in range(r+1)]
#dp
for i in range(1,r+1):
  for j in range(1,c+1):
    dp_1[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_0[i][j-1]+rck[i][j],dp_0[i][j],dp_1[i][j-1])
    dp_2[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_1[i][j-1]+rck[i][j],dp_1[i][j],dp_2[i][j-1])
    dp_3[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_2[i][j-1]+rck[i][j],dp_2[i][j],dp_3[i][j-1])
    
    
    
    
    #dp[i][j][k]=max(dp[i-1][j][3]+rck[i][j],dp[i][j-1][k-1]+rck[i][j],dp[i][j][k-1],dp[i][j-1][k])
    #print(dp[i][j])
print(dp_3[r][c])

     
      


  

### FIXED CODE ###

#dp[i][j][k]=(i,j)にアイテムをk個以下使って移動するときの最大値
#入力
r,c,k=list(map(int,input().split()))

rck=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(k):
     r_num,c_num,k_num=list(map(int,input().split()))
     rck[r_num][c_num]=k_num

#dpテーブルと初期条件
dp_0=[[0 for j in range(c+1)] for k in range(r+1)]
dp_1=[[0 for j in range(c+1)] for k in range(r+1)]
dp_2=[[0 for j in range(c+1)] for k in range(r+1)]
dp_3=[[0 for j in range(c+1)] for k in range(r+1)]
#dp
for i in range(1,r+1):
  for j in range(1,c+1):
    dp_1[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_0[i][j-1]+rck[i][j],dp_0[i][j],dp_1[i][j-1])
    dp_2[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_1[i][j-1]+rck[i][j],dp_1[i][j],dp_2[i][j-1])
    dp_3[i][j]=max(dp_3[i-1][j]+rck[i][j],dp_2[i][j-1]+rck[i][j],dp_2[i][j],dp_3[i][j-1])
    
    
    
    
    #dp[i][j][k]=max(dp[i-1][j][3]+rck[i][j],dp[i][j-1][k-1]+rck[i][j],dp[i][j][k-1],dp[i][j-1][k])
    #print(dp[i][j])
print(dp_3[r][c])
### BUGGY CODE ###

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

takahashi_cookie = A
aoki_cookie = B
iteration = K

while(0 < iteration):
    if(1 <= takahashi_cookie):
        takahashi_cookie -= 1

    elif(1 <= aoki_cookie):
        aoki_cookie -= 1

    else:
        pass

    iteration -= 1

print(str(takahashi_cookie) + ' ' + str(aoki_cookie))


### FIXED CODE ###

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

takahashi_cookie = A
aoki_cookie = B
iteration = K

if 0 <= takahashi_cookie - iteration:
  takahashi_cookie -= iteration
 
elif 0 <= aoki_cookie + takahashi_cookie - iteration:
  aoki_cookie = aoki_cookie + takahashi_cookie - iteration
  takahashi_cookie = 0

else:
  takahashi_cookie = 0
  aoki_cookie = 0

print(str(takahashi_cookie) + ' ' + str(aoki_cookie))
### BUGGY CODE ###

# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

dp[0] = 1


for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp[N])

### FIXED CODE ###

# C - Typical Stairs
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]
A = set(A)

# dp[i]: i 段目まで来た時の移動方法の総数
dp = [0]*(N+1)

# 初期条件
dp[0] = 1

for v in range(1,N+1):
    if v in A:
        continue
    dp[v] = (dp[v] + dp[v-1])%(1000000007)
    if v > 1:
        dp[v] = (dp[v] + dp[v-2])%(1000000007)
print(dp[N])
### BUGGY CODE ###

import sys
readline = sys.stdin.buffer.readline
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    H, W, K = map(int, readline().split())
    # いつものパターンと問題文のi,jが逆なので、
    # 問題文のxを変数yに、問題文のyを変数xに代入している
    sy, sx, gy, gx = map(int, readline().split())
    lake = [['@' for _ in range(W+2)]]

    for _ in range(H):
        c = ['@'] + list(readline().decode('utf-8').strip()) + ['@']
        lake.append(c)
    lake.append(['@' for _ in range(W+2)])

    dist = [[INF] * (W+2) for _ in range(H+2)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    Q = deque()
    Q.append((sy, sx))
    dist[sy][sx] = 0
    while Q:
        q = Q.popleft()
        y = q[0]
        x = q[1]
        if y == gy and x == gx:
            continue
        for i in range(4):
            for k in range(1,K+1):
                n_y = y + dy[i] * k
                n_x = x + dx[i] * k

                if lake[n_y][n_x] == '.':
                    if dist[n_y][n_x] > dist[y][x]+1:
                        dist[n_y][n_x] = dist[y][x] + 1
                        Q.append((n_y,n_x))
                    else:
                        continue

                else:
                    break

    if dist[gy][gx] == INF:
        print('-1')
    else:
        print(dist[gy][gx])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import deque
 
H, W, K = map(int,readline().split())
x1, y1, x2, y2 = map(int,readline().split())
x1 -= 1; y1 -= 1; x2 -= 1; y2 -= 1
C = read().split()

dist = [[-1]*W for i in range(H)]
dist[x1][y1] = 0
d = deque([[x1, y1]])
dxy= [[1, 0], [0, 1], [-1, 0], [0, -1]]
while d:
  x, y = d.popleft()
  if (x, y) == (x2, y2):
    print(dist[x][y])
    quit()
  for dx, dy in dxy:
    xx = x; yy = y
    for i in range(K):
      xx += dx; yy += dy
      if 0<=xx<H and 0<=yy<W and C[xx][yy]!='@':
        if 0 <= dist[xx][yy] <= dist[x][y]:
          break
        if dist[xx][yy] == -1:
           d.append([xx, yy])
        dist[xx][yy] = dist[x][y] + 1
      else:
        break

print(-1)
### BUGGY CODE ###

n = int(input())
ls = []
l = [0 for i in range(n)]
for i in range(n):
  ls.append(input())
for i in range(n):
  for j in range(10):
    alpha = ord(ls[i][j]) - ord("a")
    l[i]+=10**alpha
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if l[i] == l[j]:
      ans+=1
print(ans)


### FIXED CODE ###

n = int(input())
ls = []
dic = {}
ans = 0
for i in range(n):
    ls.append(input())
for i in range(n):
    tmp = "".join(sorted(ls[i]))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)
### BUGGY CODE ###

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

order = [0] * N
flag = 0
for i in range(0, N):
    flag = A.index(min(A))
    order[i] = flag + 1
    A[flag] = N + 1

print(" ".join(map(str, order)))


### FIXED CODE ###

N = int(input()) 
A = list(map(int,input().split()))
 
lis = []
for i in range(N):
    lis.append ([A[i],i+1])
 
lis.sort()
ans = []
for i in range(N):
    ans.append(lis[i][1])
 
print(" ".join(map(str,ans)))
### BUGGY CODE ###

N, W = map(int, input().split())

dp = [0] * (W + 1)
weights2check = [0]
for _ in range(N):
    w, v = map(int, input().split())
    new_weights2check = []
    for k in weights2check:
        if k + w <= W:
            dp[k + w] = max(dp[k + w], dp[k] + v)
            new_weights2check.append(k + w)

    weights2check += new_weights2check


ans = max(dp[i] for i in weights2check)
print(ans)

### FIXED CODE ###

N, W = map(int, input().split())

dp = [0] * (W + 1)
weights2check = [0]
ans = 0
for _ in range(N):
    w, v = map(int, input().split())
    for k in range(W-w, -1, -1):
        dp[k + w] = max(dp[k + w], dp[k] + v)
        ans = max(ans, dp[k + w])


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

import sys
input=sys.stdin.readline
class BinaryIndexedTree():
  def __init__(self,n):self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_1(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_1(j-1)
    if i!=0:a-=self.sum_1(i-1)
    return a
def tentousu(a):
  bit=BinaryIndexedTree(n)
  b=[0]*n
  for i in range(n):
    b[a[i]]=i
  ans=0
  for i in range(n):
    j=b[i]+bit.sum(b[i]+1,n)
    ans+=j-i
    bit.add(b[i],1)
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
import itertools
c=[]
for i in range(n):
  if i%2:c.append((b[i],a[i],i))
  else:c.append((a[i],b[i],i))
ans=inf=float('inf')
for i in itertools.combinations(c,(n+1)//2):
  s=set(i)
  ac=[]
  bc=[]
  for j in c:
    if j in s:ac.append((j[0],j[2]))
    else:bc.append((j[1],j[2]))
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)


### FIXED CODE ###

class BinaryIndexedTree():
  def __init__(self,n):self.bit=[0]*n
  def add(self,i,x):
    i+=1
    while i<=len(self.bit):
      self.bit[i-1]+=x
      i+=i&-i
  def sum_1(self,i):
    a=0
    i+=1
    while i:
      a+=self.bit[i-1]
      i-=i&-i
    return a
  def sum(self,i,j):
    a=self.sum_1(j-1)
    if i!=0:a-=self.sum_1(i-1)
    return a
def tentousu(a):
  bit=BinaryIndexedTree(n)
  b=[0]*n
  for i in range(n):
    b[a[i]]=i
  ans=0
  for i in range(n):
    j=b[i]+bit.sum(b[i]+1,n)
    ans+=j-i
    bit.add(b[i],1)
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(1,n,2):a[i],b[i]=b[i],a[i]
ans=inf=float('inf')
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  if s.count("0")!=n//2:continue
  ac=[]
  bc=[]
  for j in range(n):
    if s[j]=="1":ac.append((a[j],j))
    else:bc.append((b[j],j))
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)
### BUGGY CODE ###

MAX_A = 10**6 + 1
# is_prim = [True] * MAX_A
# is_prim[0] = is_prim[1] = False
# for i in range(2, MAX_A):
#     if not is_prim[i]: continue
#     for j in range(i+i, MAX_A, i): is_prim[j] = False

# 素数と個数を求める
def factorize(n):
    res = []
    for i in range(2,n):
        if i*i > n: break
        if n%i: continue
        res += [[i,0]]
        while n%i == 0:
            n //= i
            res[-1][1] += 1
    if n != 1: res += [[n,1]]
    return res

def solve():
    # prim = [i for i in range(1100) if is_prim[i]]
    C = [0] * MAX_A
    for a in A:
        for p,c in factorize(a): C[p] += 1
    max_c = max(C)
    if max_c <= 1: return 'pairwise'
    elif max_c <= n-1: return 'setwise'
    return 'not'

n = int(input())
A = [*map(int, input().split())]
print(solve(), 'coprime')


### FIXED CODE ###

n = int(input())
A = [*map(int, input().split())]
def solve():
    MAX_A = 10**6 + 1
    C = [0] * MAX_A
    for a in A: C[a] += 1
    pairwise = True
    for i in range(2, MAX_A):
        if sum(C[i:MAX_A:i]) > 1: pairwise = False
    if pairwise: return 'pairwise'
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    if g == 1: return 'setwise'
    return 'not'
print(solve(), 'coprime')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n = int(input())

    # dp[i][U] : 男 i 番目まで見た時、埋まっている女性の state が U の場合の数
    dp = {0 : 1}
    for _ in range(n):
        A = list(map(int, input().split()))
        ndp = defaultdict(int)
        for i in range(n): # match させる女性
            if not A[i]:
                continue
            for U, val in dp.items():
                if (U >> i) & 1:
                    continue
                nU = U | 1 << i
                ndp[nU] += val
                if ndp[nU] >= MOD:
                    ndp[nU] -= MOD
        dp = ndp

    print(sum(dp.values()) % MOD)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    popcount_to_state = [[] for _ in range(n + 1)]
    for U in range(1 << n):
        popcount_to_state[bin(U).count('1')].append(U)

    dp = [0] * (1 << n)
    dp[0] = 1
    for i in range(n):
        A = tuple(map(int, input().split()))
        for j in range(n):
            if not A[j]:
                continue
            for U in popcount_to_state[i]:
                if (U >> j) & 1:
                    continue
                nU = U | 1 << j
                dp[nU] += dp[U]
                if dp[nU] >= MOD:
                    dp[nU] -= MOD
    print(dp[-1])
resolve()
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,q = LI()
d = LI()
nxm = [LI() for _ in range(q)]

for n,x,m in nxm:
    e = list(map(lambda x:x%m,d))
    zero = e.count(0)
    zero = zero*((n-1)//k)
    for i in range((n-1)%k):
        if e[i] == 0:
            zero += 1
    f = list(accumulate(e))
    s = f[-1] * ((n-1)//k)
    if (n-1)%k != 0:
        s += f[(n-1)%k-1]
    tmp = (s+x%m)//m
    print(n-1-zero-tmp)

    
    


### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,q = LI()
d = LI()
nxm = [LI() for _ in range(q)]

for n,x,m in nxm:
    e = list(map(lambda x:(x-1)%m+1,d))
    f = list(accumulate(e))
    s = f[-1] * ((n-1)//k)
    if (n-1)%k != 0:
        s += f[(n-1)%k-1]
    tmp = (s+x%m)//m
    print(n-1-tmp)
### BUGGY CODE ###

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

h = int(m/n)+1
for a in range(h, 0, -1):
    q = m-a*n
    if q<0:
        continue
    else:
        if q%a == 0 and m%a == 0:
            print(a)
            break

### FIXED CODE ###

import sys

def make_divisors(num):
    divisors = []
    for i in range(1, int(num**0.5)+1):
        if num%i == 0:
            divisors.append(i)
            if num//i != i:
                divisors.append(num//i)
    divisors.sort()
    return divisors

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

divisors = make_divisors(m)

for i in range(1, len(divisors)+1):
    if divisors[i*-1] * n <= m:
        print(divisors[i*-1])
        sys.exit()