Harryxun/stf_run huggingface dataset:
import math
N = int(input())
A = [int(i) for i in input().split()]

'''
'init(a)': 配列aで初期化。O(N)
'update(k,x)': a[k]をxに変更 O(logN)
'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
'ide_ele' : 単位元。
'''


def segfunc(x, y):
    return math.gcd(x, y)


def init(init_val):
    # set_val
    for i in range(N):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])


def update(k, x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1], seg[k*2+2])


def query(p, q):
    if q <= p:
        return ide_ele
    p += num-1
    q += num-2
    res = ide_ele
    while q-p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元######
ide_ele = A[-1]

# num:n以上の最小の2のべき乗
num = 2**(N-1).bit_length()
seg = [ide_ele]*2*num

init(A)

# print(query(0, 2))

ans = 1
for i in range(N):
    ans = max(ans, math.gcd(query(0, i), query(i+1, N)))
print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

N=int(input())
A=[int(i) for i in input().split()]

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

ans=1
for i in range(N):
    c=mygcd(L[i],R[i])
    ans=max(ans,c)

print(ans)
n = int(input())
book=[]
for i in range(n):
    a,b=input().split()
    temp=[a,int(b),i+1]
    book.append(temp)

book.reverse(key = lambda x:x[1])
book.sort(key = lambda x:x[0])

for j in range(len(book)):
    print(book[j][2])


### FIXED CODE ###

n = int(input())
l = [input().split()+[i+1] for i in range(n)]
for i in range(n):
    l[i][1] = int(l[i][1])
l = sorted(l, key=lambda x : x[1], reverse=True)
l = sorted(l, key=lambda x : x[0])
for i in range(n):
    print(l[i][2])
A = int(input())
B = input()
k = int(input())
for v in B:
    print(B if k[k-1] == B else "*",end="")

### FIXED CODE ###

input()
B = input()
k = int(input())
for v in B:
    print(v if B[k-1] == v else "*",end="")
N=int(input())
xyh=[list(map(int, input().split())) for i in range(N)]

for i in range(101):
  for j in range(101):
    check=True
    h=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
    
    for k in range(1, N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if h!=temph:
        check=False
        
    if check:
      if 0<=h<=pow(10, 9):
      print(' '.join([str(i), str(j), str(h)]))

### FIXED CODE ###

N=int(input())
xyh=[list(map(int, input().split())) for i in range(N)]
 
for i in range(101):
  for j in range(101):
    check=True
    k=0
    while xyh[k][2]==0:
      k+=1
      
    h=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
    
    for k in range(N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if xyh[k][2]==0:
        if temph<h:
          check=False
      else:
        if h!=temph:
          check=False
        
    if check==True and 0<h:
        print(' '.join([str(i), str(j), str(h)]))
        exit()
        
sonnnakannsuuhateigisiteinai()
import sys
n, m = map(int, input().split())

sys.setrecursionlimit(10**5)

breakstep = []

for _ in range(m):
    breakstep.append(int(input()))

sl = [-1 for _ in range(n+1)]

def solve(i):
    if sl[i] == -1:
        if i in breakstep:
            sl[i] = 0
        elif i in [0, 1]:
            sl[i] = 1
        else:
            sl[i] = (solve(i-1) + solve(i-2)) % 1000000007
    return sl[i]

print(solve(n))

### FIXED CODE ###

import math
from collections import deque

memo = deque([1, 2])
floor = 1
def search(x):
    global memo, floor
    while x > floor:
        memo.append(memo[-1] + memo[-2])
        floor += 1
    return memo[x-1]

CONST = 1000000007
n,m = map(int,input().split())
lis = []
prev = -1
for _ in range(m):
    a = int(input())
    if prev + 1 == a:
        print(0)
        exit()
    lis.append(a-prev-2)
    prev = a
lis.append(n-prev-1)


ans = 1
for v in lis:
    if v == 0: continue
    ans = (ans * search(v)) % CONST
print(ans)
import numpy as np

n,m,x = map(int,input().split())
arr = np.array([list(map(int,input().split())) for i in range(n)])
c = arr.T[0] # c[n-1]まで
a = arr.T[1:].T # a[n-1][m-1]まで

ans = np.inf
for i in range(2**n):
    ability = np.zeros(m, np.int64)
    cost = 0
    # 二進数の右から0番目〜n-1番目をみていき、使用or不使用を判断
    for j in range(n):
    # 使用する場合にability/costを更新
        if (i>>j)&1: ability += a[j] ; cost += c[j]
    # 条件クリアしている場合にansを更新
    if np.all(ability>=x): ans = min(ans,cost)

# ansが無限なら、未更新＝条件クリアしてないので-1を出力
ans = -1 if ans==np.inf else ans
print(ans)


### FIXED CODE ###

import numpy as np
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]

ans = np.inf
flag = 0
for i in range(2**n):
    r = np.array([0]*(m+1))
    for j in range(n):
        if (i>>j)&1:
            for k in range(m+1): r[k] += a[j][k]
    if np.all(r[1:]>=x):
        if ans > r[0]: ans = r[0]
        flag = 1
    else: flag = 0

if flag: print(ans)
else: print("-1")
a,b,c = list(map(int,input().split()))
print(c+" "+a+" "+b)

### FIXED CODE ###

A = list(map(int,input().split()))
print(str(A[2])+" "+str(A[0])+" "+str(A[1]))
s=input()
q=int(input())
query=[]
for i in range(q):
    query.append(input())
rev=0
before=""
after=""
for i in range(q):
    if query[i][0]=="1":
        rev+=1
    else:
        n,f,c=query[i].split()
        if (rev+int(f))%2==0:
            after=after+c
        else:
            before=c+before
seqfin=before+s+after
if rev%2==0:
    print(seqfin)
else:
    for i in range(len(seqfin)):
        print(seqfin[len(seq)-i-1],end="")

### FIXED CODE ###

s=input()
q=int(input())
query=[]
for i in range(q):
    query.append(input())
rev=0
bef=""
aft=""
for i in range(q):
    if query[i][0]=="1":
        rev+=1
    else:
        n,f,c=query[i].split()
        if (rev+int(f))%2==0:
            aft=aft+c
        else:
            bef=c+bef
seqfin=bef+s+aft
if rev%2==0:
    print(seqfin)
else:
    print(seqfin[::-1])
as = map(int, input().split())

if as.sum() <= 21:
  print("win")
else:
  print("bust")

### FIXED CODE ###

as_ = map(int, input().split())
 
if sum(as_) <= 21:
  print("win")
else:
  print("bust")
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
K = N

i = 1
while K > 26**i:
	K -= 26**i
	i += 1

ans = ""
for j in range(i-1, -1, -1):
	ans += ascii_lowercase[N//26**j-1]
	N %= 26**j

print(ans)




### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
i = 1
while N > 26**i:
	N -= 26**i
	i += 1

ans = ""
N -= 1
for j in range(i-1, -1, -1):
	ans += ascii_lowercase[N//(26**j)]
	N %= 26**j

print(ans)
def funcs(a, b, c):
    x = int(a)
    y = int(b)
    z = int(c)

    if x < y < z:
        print("Yes")
    else:
        print("No")


tmp = input()

a, b = tmp.split(" ")

funcs(a, b)



### FIXED CODE ###

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

if l[0] < l[1] < l[2]:
    print('Yes')
else:
    print('No')
n,m = map(int,input().split())
AB = []
ans = [0] * (n-1)

for i in range(m):
    AB.append(list(map(int,input().split())))
    
import collections
que = collections.deque()
que.append(1)
    
while que:
    x = que.popleft()
    
    for i in AB:
        a = i[0]
        b = i[1]
        
        if a == x and ans[b-2] == 0:
            ans[b-2] = x
            que.append(b)
        elif b == x and ans[a-2] == 0:
            ans[a-2] = x
            que.append(a)
            
if 0 in ans:
    print("No")
else:
    print("Yes")
    
    for i in ans:
        print(i)

### FIXED CODE ###

n = int(input())

if n % 10 == 3:
    print("bon")

elif n % 10 in [0,1,6,8]:
    print("pon")
    
else:
    print("hon")
a=[int(input()) for _ in range(3)]
b=sorted(a)
if b[0]==5 and b[1]==5 and b[2]==7:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

a=list(map(int,input().split()))
print(['NO','YES'][a.count(5)==2 and a.count(7)==1])
# https://atcoder.jp/contests/agc008/tasks/agc008_a
# どう見ても符号反転は1回するのが最適
# ひたすら場合分け


x, y = map(int, input().split())
if x > 0:
    if x < y:
        print(y - x)
    elif 0 <= y:  # ここがちがうまじ？
        print(x + y + 1)
    else:
        print(min(1 + x + y, -y - x + 1, key=lambda z: 10 ** 10 if z < 1 else z))
        raise ValueError('')
else:  # xが負
    if y < x:
        print(2 + x - y)
    elif y <= 0:
        print(y - x)
    else:
        print(min(y - x, 1 + y + x, key=lambda z: 10**10 if z < 1 else z))


### FIXED CODE ###

# https://atcoder.jp/contests/agc008/tasks/agc008_a
# どう見ても符号反転は1回するのが最適
# ひたすら場合分け


x, y = map(int, input().split())
if x * y < 0:  # 異符号ならば答えは一つ
    print(abs(abs(x) - abs(y)) + 1)
    exit()
elif 0 <= x < y:
    print(y - x)
    exit()
elif 0 < y < x:
    print(2 + x - y)
    exit()
elif y == 0 and y < x:
    print(1 + x)
    exit()
elif x < y <= 0:
    print(y - x)
    exit()
elif y < x < 0:
    print(2 + x - y)
    exit()
elif x == 0 and y < x:
    print(1 - y)
    exit()
raise ValueError()
N,K = map(int,input().split())
H = sorted(list(map(int,input().split())))

for i in range(K):
  H.pop()

print(sum(H))

### FIXED CODE ###

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

for i in range(K):
  if len(H) == 0:
    break
  H.pop()

print(sum(H))
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(S):
    x = S
    if len(S) == 2:
        return S
    elif len(S) == 3 :
        return x[2] + x[1] + x[0]

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

s = input()

x = s
if len(s) == 2 :
    print (s)
elif len(s) == 3 :
    print (x[2] + x[1] + x[0])
S = input()
back = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = S

print(n);

### FIXED CODE ###

S = input()
back = 0
n = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = i

print(n);
n,k,s = map(int,input().split())
l = []
if n == k:
    l = [s]*n
    for i in range(n):
        print(a[i], end=" ")
else:
    if s%2:
        for i in range(k+1):
            print(i)
            if i%2:
                l += [int(s/2)]
            else:
                l += [int(s/2)+1]
        if s == 1 or s == 3:
            l += [100]*(n-(k+1))
        else:
            l += [1]*(n-(k+1))
    elif s != 2:
        l = [int(s/2)]*(k+1) + [int(s/2)+1]*(n-k-1)
    else:
        l = [int(s/2)]*(k+1) + [100]*(n-k-1)
        
    for i in range(n):
        print(l[i], end=" ")

### FIXED CODE ###

n,k,s = map(int,input().split())
for i in range(1,n+1):
    if i <=k:
        print(s)
    elif s == 10**9:
        print(1)
    else:
        print(10**9)
from sys import stdin
A,B = map(int, stdin.readline().rstrip().split())

def search(x):
    p = (x*0.08)//1
    q = (x*0.10)//1
    if p==A and q==B:
        print(x)
        exit()
    elif p > A or q > B:
        print(-1)
    else:
        search(x+1)

search(1)


### FIXED CODE ###

from sys import stdin
import sys
A,B = map(int, stdin.readline().rstrip().split())
sys.setrecursionlimit(2000)
def search(x):
    p = (x*0.08)//1
    q = (x*0.10)//1
    if p==A and q==B:
        print(x)
        exit()
    elif p > A and q > B:
        print(-1)
    else:
        search(x+1)

search(1)
import sys
input=sys.stdin.readline
h, w, d = map(int, input().split())
p = dict()
for i in range(h):
    for j, x in enumerate(map(int, input().split())):
        p[x] = (i, j)

dist = [[None]*(h*w) for _ in p.keys()]

def func(a, b):

    if a == b:
        dist[a][b] = 0
        return 0
    else:
        if dist[a][b]:
            return dist[a][b]
        else:
            x, y = p[b]
            s, t = p[b-d]
            dist[b-d][d] = abs(x-s)+abs(y-t)
            return func(a, b-d) + dist[b-d][d]


q = int(input())
for i in range(q):
    a, b = map(int, input().split())
    ans = func(a, b)
    print(ans)


### FIXED CODE ###

import sys
input=sys.stdin.readline
h, w, d = map(int, input().split())
p = dict()

for i in range(h):
    for j, x in enumerate(map(int, input().split())):
        p[x] = (i, j)

dp = [0]*(h*w+1)
for i in range(h*w+1):
    if d < i:
        dp[i] = dp[i-d] + abs(p[i][0]-p[i-d][0])+abs(p[i][1]-p[i-d][1])

q = int(input())
for i in range(q):
    a, b = map(int, input().split())
    ans = dp[b]-dp[a]
    print(ans)
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y)//math.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
print(ans)

### FIXED CODE ###

import math
from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y)//fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
print(ans)
N,M = map(int,input().split())
ans = [0]*N
for _ in range(M):
  ans[int(input())-1] += 1

for a in ans:
  print(a)

### FIXED CODE ###

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

for a in ans:
  print(a)
import sys
input = sys.stdin.readline


def main():
    limit = 10**18
    N = int(input())
    A = list(map(int, input().split()))
    assert N == len(A)
    answer = 1
    for i in A:
        answer *= i
        if answer > limit:
            print("-1")
            exit()
        elif answer == 0:
            print(answer)
            exit()
    print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    A, B = map(int, input().split())
    print(A*B)


if __name__ == '__main__':
    main()
s_a = input()
s_b = input()
s_c = input()
x = s_a[0]
while( len(s_a) >= 0 and len(s_b) >=0 and len(s_c) >= 0):

    print(s_a,s_b,s_c,1)
    if x == 'a':
        x = s_a[0]
        s_a = s_a[1:]
        print(s_a,s_b,s_c,2)
    if x == 'b':
        x = s_b[0]
        s_b = s_b[1:]
        print(s_a,s_b,s_c,3)
    if x == 'c':
        x = s_c[0]
        s_c = s_c[1:]
        print(s_a,s_b,s_c,4)
    if x == 'a' and len(s_a) == 0:
        print('A')
        break
    if x == 'b' and len(s_b) == 0:
        print('B')
        break
    if x == 'c' and len(s_c) == 0:
        print('C')
        break


### FIXED CODE ###

s_a = input()
s_b = input()
s_c = input()
x = s_a[0]
while( len(s_a) >= 0 and len(s_b) >=0 and len(s_c) >= 0):

    if x == 'a':
        x = s_a[0]
        s_a = s_a[1:]


    elif x == 'b':
        x = s_b[0]
        s_b = s_b[1:]

    elif x == 'c':
        x = s_c[0]
        s_c = s_c[1:]


    if x == 'a' and len(s_a) == 0:
        print('A')
        break
    if x == 'b' and len(s_b) == 0:
        print('B')
        break
    if x == 'c' and len(s_c) == 0:
        print('C')
        break
N=int(input())
A=list(map(int,input().split()))
Even = []
Odd = []
A.sort()
for a in A:
    if a % 2 == 0:
        a.append(Even)
    if a % 2 == 1:
        a.append(Odd)
if len(Odd) % 2 == 1:
    print('NO')
else:
    print('YES')
        

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
Even = []
Odd = []
A.sort()
for a in A:
    if a % 2 == 0:
        Even.append(a)
    if a % 2 == 1:
        Odd.append(a)
if len(Odd) % 2 == 1:
    print('NO')
else:
    print('YES')
n, k = map(int, input().split())
s = input()

a = []
j = 0
temp = 1
prev = s[0]
for i in s[1:]:
    if i == prev:
        prev = i
        temp += 1
    else:
        a.append(temp)
        prev = i        
        temp = 1
a.append(temp)

b = []
if s[0] == "1":
    b.append(sum(a[:2*k+1]))
    for i in range(len(a) - 2*k - 1):
        b.append(b[-1] - a[i] + a[2*k+i+1])
    print(max(b))
else:
    t = a[1:]
    b.append(sum(t[:2*k+1]))
    for i in range(len(a) - 2*k - 1):
        b.append(b[-1] - t[i] + t[2*k+i+1])
    b.append(sum(a[:2*k]))
    print(max(b))

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
hand_list = []
for i in range(n):
    if i == 0:
        hand_list.append(i)
    else:
        if s[i] != s[i - 1]:
            hand_list.append(i)
hand_list.append(n)

ans_list = []
if len(hand_list) > 2 * k:
    for i in range(len(hand_list) - 2 * k):
        if s[hand_list[i]] == '1':
            ans = hand_list[min(i + 2 * k + 1, len(hand_list)-1)] - hand_list[i]
        else:
            ans = hand_list[i + 2 * k] - hand_list[i]
        ans_list.append(ans)
else:
    ans_list.append(n)
print(max(ans_list))
arguments = input("test")
arguments_as_list = arguments.split(" ")
list_to_integer = list(map(int, arguments_as_list))
apples_pieces = list_to_integer[0]*3
pieces = list_to_integer[1]


print(int((apples + pieces)//2))



### FIXED CODE ###

arguments = input()
arguments_as_list = arguments.split(" ")
list_to_integer = list(map(int, arguments_as_list))
apples_pieces = list_to_integer[0]*3
pieces = list_to_integer[1]


print(int((apples_pieces + pieces)//2))
def main():
    n = int(input())
    abc = 'abcdefghijklmnopqrstuvwxyz'

    length = 1
    accumulation = 0
    while True:
        if n <= 26 ** length + accumulation:
            break
        else:
            accumulation += 26 ** length
            length += 1


    if length == 1:
        answer = abc[n - 1]

    else:
        lst = []
        for _ in range(length - 1):
             if n % 26 != 0:
                 tmp = n // (26 ** (length - 1))
             else:
                 tmp = (n - 1) // (26 ** (length - 1))

             lst.append(tmp)
             n -= (26 ** (length - 1) * tmp)
             length -= 1

        lst.append(n)

        answer = ''
        for i in range(len(lst)):
            number = lst[i]
            answer += abc[number - 1]


    print(answer)



if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    alp = 'abcdefghijklmnopqrstuvwxyz'
    answer = ''

    while n >= 1:
        n -= 1
        answer += alp[n % 26]
        n //= 26

    real_answer = ''
    for i in range(1, len(answer) + 1):
        real_answer += answer[-i]

    print(real_answer)


if __name__ == '__main__':
    main()
z=r*r
print z

### FIXED CODE ###

r= input()
print r**2
A,B=map(int,input())
if A+B>=10:
  print('error')
else:
  print(A+B)

### FIXED CODE ###

A,B=map(int,input().split())
if A+B>=10:
  print('error')
else:
  print(A+B)
import math

def eratosthenes():
    erat = [0 for _ in range(max(a)+1)]
    lim = int(math.sqrt(max(set_a)))
    for i in range(2, lim+1):
        cnt = 0
        if not erat[i]:
            for res in range(i, max(set_a)+1, i):
                if res in set_a:
                    cnt += 1
                erat[i] = i
                if cnt > 2:
                    break
        else:
            continue
        break
    return cnt


n = int(input())
a = [int(x) for x in input().split()]
set_a = set(a)

ans = eratosthenes()

if max(ans.values()) == 1 and len(set_a) == n:
    print('pairwise coprime')
else:
    res = a[0]
    for i in range(n):
        res = math.gcd(res, a[i])
    if res == 1:
        print('setwise coprime')
    else:
        print('not coprime')

### FIXED CODE ###

import math

def eratosthenes():
    erat = [0 for _ in range(max_a+1)]
    #lim = int(math.sqrt(max_a))
    pair = True
    #for i in range(2, lim+1):
    for i in range(2, max_a+1):
        cnt = 0
        if not erat[i]:
            for res in range(i, max_a+1, i):
                if res in set_a:
                    cnt += 1
                erat[res] = i
                if cnt > 1:
                    pair = False
                    break
        if not pair:
            break
    return pair


n = int(input())
a = [int(x) for x in input().split()]
max_a = max(a)
set_a = set(a)

if eratosthenes() and len(set_a) == n - max(0, a.count(1)-1):
    print('pairwise coprime')
else:
    res = a[0]
    for i in range(n):
        res = math.gcd(res, a[i])
    if res == 1:
        print('setwise coprime')
    else:
        print('not coprime')
N, Q = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(N-1)]
operations = [list(map(int, input().split())) for _ in range(Q)]

edge_map = {}
for i in range(N):
    edge_map[i] = []

for edge in edges:
    a = edge[0]
    b = edge[1]
    edge_map[a-1].append(b-1)
    edge_map[b-1].append(a-1)


counters = [0 for i in range(N)]

for operation in operations:
    p = operation[0]
    x = operation[1]
    counters[p-1] += x


res_list = [counters[i] for i in range(N)]
calculated = [False for i in range(N)]

def dfs_res(idx, parent, diff):
    global res_list
    global counters
    if calculated[i]:
        return res_list[idx]
    res = counters[idx] + diff
    res_list[idx] = res
    calculated[idx] = True
    for child in edge_map[idx]:
        if child == parent:
            continue
        dfs_res(child, idx, res)
    return

dfs_res(0, None, 0)

ans = ""
for res in res_list:
    ans += str(res) + " "
print(ans)


### FIXED CODE ###

from collections import deque
N, Q = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(N-1)]
operations = [list(map(int, input().split())) for _ in range(Q)]

edge_map = [[] for i in range(N)]

for edge in edges:
    a = edge[0]
    b = edge[1]
    edge_map[a-1].append(b-1)
    edge_map[b-1].append(a-1)


counters = [0]*N

for operation in operations:
    p = operation[0]
    x = operation[1]
    counters[p-1] += x


res_list = [counters[i] for i in range(N)]
calculated = [False for i in range(N)]

target = [0]
while len(target) > 0:
    t = target.pop()
    calculated[t] = True
    for child in edge_map[t]:
        if calculated[child]:
            continue
        target.append(child)
        res_list[child] += res_list[t]

print(*res_list)