Harryxun/stf_run huggingface dataset:
n=int(input())
a=list(map(int, input().split()))
r=[0]*n

# 平滑化
for i in range(n):
    a1,a2,a3=a[i-1], a[i], a[(i+1)%n]
    if a2 > a1:
        r[i+1]+=(a2-a1)*2
        a[i]-=(a2-a1)
        a[i+1]-=(a2-a1)
    if a2 > a3:
        r[i]+=(a2-a3)*2
        a[i]-=(a2-a3)
        a[i-1]-=(a2-a3)

b=max(a)
print(" ".join(list(map(lambda x: str(x+b), r))))

### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
r=[0]*n

while max(a) != min(a):
    for i in range(n):
        a1,a2,a3=a[i-1], a[i], a[(i+1)%n]
        if a2 > a1:
            val=min(a3, a2-a1)
            r[(i+1)%n]+=val*2
            a[i]-=val
            a[(i+1)%n]-=val
        if a2 > a3:
            val=min(a1, a2-a3)
            r[i]+=val*2
            a[i]-=val
            a[i-1]-=val

    for i in range(n)[::-1]:
        a1,a2,a3=a[i-1], a[i], a[(i+1)%n]
        if a2 > a1:
            val=min(a3, a2-a1)
            r[(i+1)%n]+=val*2
            a[i]-=val
            a[(i+1)%n]-=val
        if a2 > a3:
            val=min(a1, a2-a3)
            r[i]+=val*2
            a[i]-=val
            a[i-1]-=val

b=max(a)
print(" ".join(list(map(lambda x: str(x+b), r))))
class UnionFind:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [1] * N

    def root(self, x):
        px = self.par[x]
        if px == x:
            return x
        else:
            self.par[x] = self.root(px)
            return self.par[x]

    def unite(self, x, y):
        rootx = self.root(x)
        rooty = self.root(y)
        rankx = self.rank[rootx]
        ranky = self.rank[rooty]
        if rootx == rooty:
            return 0
        elif rankx < ranky:
            self.par[rooty] = rootx
            self.rank[rootx] += ranky
            return rankx * ranky
        else:
            self.par[rootx] = rooty
            self.rank[rooty] += rankx
            return ranky * rankx 
    
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

N, M = map(int, input().split())
tree = UnionFind(N)
li = [list(map(int, input().split())) for i in range(M)]
inconv = [0] * M
for i in range(M-1, -1, -1):
    inconv[i] = tree.unite(li[i][0]-1, li[i][1]-1)
    
temp = 0
for i in range(M):
    temp += inconv[i]
    print(temp)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

class UnionFind:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.rank = [1] * N

    def root(self, x):
        px = self.par[x]
        if px == x:
            return x
        else:
            self.par[x] = self.root(px)
            return self.par[x]

    def unite(self, x, y):
        rootx = self.root(x)
        rooty = self.root(y)
        rankx = self.rank[rootx]
        ranky = self.rank[rooty]
        if rootx == rooty:
            return 0
        elif rankx < ranky:
            self.par[rooty] = rootx
            self.rank[rootx] += ranky
            return rankx * ranky
        else:
            self.par[rootx] = rooty
            self.rank[rooty] += rankx
            return ranky * rankx 
    
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

N, M = map(int, input().split())
tree = UnionFind(N)
li = [list(map(int, input().split())) for i in range(M)]
inconv = [0] * M
for i in range(M-1, -1, -1):
    inconv[i] = tree.unite(li[i][0]-1, li[i][1]-1)
    
temp = 0
for i in range(M):
    temp += inconv[i]
    print(temp)
def tax(p,x):
    return p*(100+x) // 100
def solve(X,Y,S):
    for a in range(1,S):
        for b in range(1,S-a+1):
            sum = tax(a,X)+tax(b,X)
            if sum == S:
                NS = tax(a,Y)+tax(b,Y)
                A=NS
            if sum > S:
                break
    return A 
while True:
    X,Y,S = map(int, input().strip().split('')) 
    if X == 0:
        break
    print(solve(X,Y,S))


### FIXED CODE ###

def tax(p,x):
    return p*(100+x) // 100

def solve(X,Y,S):
    A=0
    sum=0
    NS=0
    for a in range(1,S):
        for b in range(1,S-a+1):
            sum = tax(a,X)+tax(b,X)
            if sum == S:
                NS = tax(a,Y)+tax(b,Y)
                if NS > A:
                    A = NS
            if sum > S:
                break
    return A 

while True:
    X,Y,S = map(int, input().split()) 
    if X == 0:
        break
    print(solve(X,Y,S))
n,m = map(int,input().split())
ans = [0]*(m+1)
for i in range(n):
  l = list(map(int,input().split()))
  for j in range(1,l[1]+1):
    ans[l[j]] += 1
        
for i in ans:
  if i == n:
    count += 1
print(count)
        
    

### FIXED CODE ###

n,m = map(int,input().split())
ans = [0]*(m+1)
count = 0
for i in range(n):
  l = list(map(int,input().split()))
  for j in range(1,l[0]+1):
    ans[l[j]] += 1
        
for i in ans:
  if i == n:
    count += 1
print(count)
H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

  print(mp_min)

print(mp_min[-1])


### FIXED CODE ###

H, N = map(int, input().split())
ATK = []

for i in range(N):	
  ATK.append(list(map(int, input().split())))
mp_min = [0]
for hp in range(1, H+1):
  mp_min.append(min([mp_min[max(0, hp-ATK[i][0])] + ATK[i][1] for i in range(N)]))

 # print(mp_min)

print(mp_min[-1])
a=str(input())
if a.islower():
    print(a)
else:
    print(A)

### FIXED CODE ###

a=str(input())
if a.islower()==True:
    print('a')
else:
    print('A')
a,b = [ = [int(v) for v in input().split(" ")]

d = a+b
e = a-b
f = a*b
print(max(max(d,e),f))


### FIXED CODE ###

a,b = [int(v) for v in input().split(" ")]

d = a+b
e = a-b
f = a*b
print(max(max(d,e),f))
n,a,b=amap(int,input().split())
print(min(b,a*n))

### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(b,a*n))
P8, P10 = map(int, input().split())


import math
price1_min = math.ceil(P8/0.08)

price1_max = math.floor((P8+1)//0.08)

price2_min = math.ceil(P10/0.10)

price2_max = math.floor((P10+1)//0.10)



if (price1_max >= price2_min) and (price2_max >= price1_min):
    print(max(price2_min, price1_min))
else: 
    print(-1)

### FIXED CODE ###

stations = input()
if (not "A" in stations) or (not "B" in stations):
  print("No")
else:
  print("Yes")
def convert(S): 
  
    
    str1 = ""  # initialization of string to "" 
    return(str1.join(S))    # using join function join the list s by  
                            # separating words by str1


K = int(input())    # take K from user
readtext= str(input())  # take the input string 

S = list(readtext)   #split the string into charactrers and put them to list
list1=[]  #list 1 

for i in range (0 , K): # for looop to append the charachters to the new list
   
    list1.append(S[i]) # appending the charachters to the list
if len(S) > K:  # condition when number of charachters is big than K
    b = "..."
    list1.append(b) # append the 3 dots 

print(convert(list1)) # convert the list of characters back to the string format

### FIXED CODE ###

num=int(input()) #ask integer for limitation
s=input() #ask string
if len(s) > num:    #check if the length s exceeded num
    print(s[:num] + "...")  #print s with the limit "num"
else:   #if the string not exceeded num
    print(s)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import itertools
input()
lis = list(itertools.product([False,True],repeat=10))
for s in sys.stdin:
  d = map( int, s.split() )
  flag = False
  for e in lis:
    l = [ d[i] if e[i] else -d[i] for i in xrange(10) ]
    m = [ [ e for e in l if e > 0 ],[ -e for e in l if e < 0 ]]
    n = 0
    for e in m:
      n += sum([ 1 if e[i] > e[i+1] else 0 for i in range(len(e)-1)])
    if not n:
      print "YES"
      break
  if n:
    print "NO"

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = input()
for s in xrange(n):
  d = map( int, raw_input().split() )
  a = b = 0
  flag = True
  for e in d:
    if a < e: a = e
    elif b < e: b = e
    else: flag = False
  if flag: print "YES"
  else: print "NO"
def func(n):
    return (n * (n - 1)) // 2


node_size, input_size = [int(i) for i in input().split()]

br = [func(node_size)]
for _ in range(input_size):
    br.append([int(i) for i in input().split()])

cnt_list = [func(node_size)]

index = 0
node_to_group = {}
group_to_index = {}
index_size = {}

for j in range(1, input_size + 1):
    flag1, flag2 = br[-j][0] in node_to_group, br[-j][1] in node_to_group

    if flag1 and flag2:
        if group_to_index[node_to_group[br[-j][0]]] == group_to_index[node_to_group[br[-j][1]]]:
            tmp = cnt_list[0]
        else:
            tmp = cnt_list[0] + func(index_size[group_to_index[node_to_group[br[-j][0]]]]) + \
                  func(index_size[group_to_index[node_to_group[br[-j][1]]]]) - \
                  func(index_size[group_to_index[node_to_group[br[-j][0]]]] +
                       index_size[group_to_index[node_to_group[br[-j][1]]]])
            index_size[group_to_index[node_to_group[br[-j][0]]]] += index_size[group_to_index[node_to_group[br[-j][1]]]]
            del index_size[group_to_index[node_to_group[br[-j][1]]]]
            group_to_index[node_to_group[br[-j][1]]] = group_to_index[node_to_group[br[-j][0]]]

    elif flag1:
        tmp = cnt_list[0] - index_size[group_to_index[node_to_group[br[-j][0]]]]
        node_to_group[br[-j][1]] = node_to_group[br[-j][0]]
        index_size[group_to_index[node_to_group[br[-j][0]]]] += 1
    elif flag2:
        tmp = cnt_list[0] - index_size[group_to_index[node_to_group[br[-j][1]]]]
        node_to_group[br[-j][0]] = node_to_group[br[-j][1]]
        index_size[group_to_index[node_to_group[br[-j][1]]]] += 1
    else:
        tmp = cnt_list[0] - 1
        node_to_group[br[-j][0]] = br[-j][0]
        node_to_group[br[-j][1]] = br[-j][0]
        group_to_index[br[-j][0]] = index
        index_size[index] = 2
        index += 1
    print(index_size)
    if tmp == 0:
        for _ in range(input_size - j):
            print(0)
        break
    cnt_list.insert(0, tmp)

for i in cnt_list:
    print(i)

### FIXED CODE ###

def search_root(l, n):
    i = n
    while l[i] != i:
        i = l[i]
    return i


def set_root(l, root_index, start_index):
    i = start_index
    while l[i] != root_index:
        tmp = i
        i = l[i]
        l[tmp] = root_index


def func(n):
    return (n * (n - 1)) // 2


node_size, input_size = [int(i) for i in input().split()]

br = []
for _ in range(input_size):
    br.append([int(i) for i in input().split()])

cnt_list = [0]
size_list = [1 for _ in range(node_size + 1)]
node_list = [i for i in range(node_size + 1)]

for i in range(1, input_size + 1):
    node1, node2 = br[-i]

    root1, root2 = search_root(node_list, node1), search_root(node_list, node2)

    if root1 == root2:
        cnt_list.append(cnt_list[-1])
    else:
        cnt_list.append(cnt_list[-1] + (size_list[root1] * size_list[root2]))
        if size_list[root1] < size_list[root2]:
            node_list[root1] = root2
            size_list[root2] += size_list[root1]
        else:
            node_list[root2] = root1
            size_list[root1] += size_list[root2]

val = func(node_size)
for i in cnt_list[::-1][1:]:
    print(val - i)
a=int(input())
s=string(input())
if (a>=3200) :
 print(s)
else :
 print("red")


### FIXED CODE ###

a=int(input())
s=(input())
if (a>=3200) :
 print(s)
else :
 print("red")
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    if (2*x-y)%3>0 or (2*y-x)%3>0:
        print(0)
    else:
        n=(2*x-y)//3
        m=(2*y-x)//3
        print(mod_comb4(n+m,n,mod)%mod)


if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    n=2*x-y
    m=2*y-x
    if n%3==0 and m%3==0 and n>=0 and m>=0:
        print(mod_comb4(n//3+m//3,n//3,mod))
    else:
        print(0)


if __name__=='__main__':
    main()
import math
LIM = 182

def solve(n):
    ans = 0
    for a in range(1,LIM):
        tmp = a*a
        if tmp == n:
            ans += 1
        if tmp >= n:
            break
        for b in range(a,LIM):
            tmp2 = tmp + b*b
            if tmp2 == n:
                ans += 1
            if tmp2 >= n:
                break
            for c in range(b,LIM):
                tmp3 = tmp2 + c*c
                if tmp3 == n:
                    ans += 1
                if tmp3 >= n:
                    break
                d = int(math.sqrt(n - tmp3))
                if tmp3 + d*d == n and c <= d:
                    ans += 1
    return ans

while True:
    N = int(input())
    if N == 0: break
    print(solve(N))

### FIXED CODE ###

MAXN = 2**15
MAXRT = int(MAXN**0.5)
MAXTERM = 4

dp = [[0 for n in range(MAXN+1)] for t in range(MAXTERM+1)]
dp[0][0] = 1
for r in range(MAXRT,0,-1):
    for t in range(MAXTERM):
        for n in range(MAXN+1 - r*r):
            if dp[t][n] == 0: continue
            dp[t+1][n + r*r] += dp[t][n]

while True:
    N = int(input())
    if N == 0: break
    print(sum(map(lambda x:x[N],dp)))
from collections import Counter
N=int(input())
L=[]
for i in range(N):
   L.append(list(input()))
L1=Counter(L[0])&Counter(L[1])
for i in range(2,N):
    L1=Counter(L[i])&L1
ans=[i*L1[i] for i in L1]
print("".join((ans)))


### FIXED CODE ###

from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))
from collections import Counter
N, X, Y = map(int, input().split())
ans = []

for i in range(N):
    for j in range(i+1, N):
        ans.append(min(j-i, 1+abs(i-x)+abs(j-Y)))

c = Counter(ans)
for i in range(1,N):
    print(c[i])


### FIXED CODE ###

from collections import Counter
N, X, Y = map(int, input().split())
X, Y = X-1, Y-1
ans = []

for i in range(N):
    for j in range(i+1, N):
        ans.append(min(j-i, 1+abs(i-X)+abs(j-Y)))

c = Counter(ans)
for i in range(1,N):
    print(c[i])
n,k = map(int, input().split())
d = sorted([int(input()) for _ in range(n)],reverse=True)
ret = 9999999999
#print(d)
for i in range(n-k+1):
    #print(i,i+k-1)
    ret = min(ret,d[i]-d[i+k-1])
print(ret)


### FIXED CODE ###

print("Christmas "+("Eve "*(25-int(input()))))
n,x=map(int,input().split())
L = list(map(int,input().split()))
count=0
D=0
for i in range(n+1):
    if D>x:
        print(count)
        break
    else:
        D=D+L[i]     
        count+=1


### FIXED CODE ###

n,a=map(int,input().split())
if n>=a:
    print(10)
else:
    print(0)
n = int(input())
a = list(map, input().split())
suma = sum(a)
if sum(a) % (n*(n+1)//2) > 0:
  print('NO')
  exit()
k = 2*suma//(n*(n+1))
diffs = [a[i+1] - a[i] + k for i in range(n-1)]
if all([d % n == 0 for d in diffs]):
  print('YES')
else:
  print('NO')


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if n == 1:
    print('YES')
    exit()
suma = sum(a)
if sum(a) % (n*(n+1)//2) > 0:
    print('NO')
    exit()
k = 2*suma//(n*(n+1))
diffs = [a[i+1] - a[i] - k for i in range(-1, n-1)]
if all([d<=0 and -d % n == 0 for d in diffs]):
    print('YES')
else:
    print('NO')
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    if N == 5:
        raise Exception
    elif N==6:
        while 1:
            pass
    else:
        print("No")
if __name__ == '__main__':
    main()

### FIXED CODE ###

#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    N*=2
    size = -1
    group_num = -1
    for i in range(2,N+2):
        if i*(i-1)==N:
            group_num = i
            size = i-1
            break
    if size == -1:
        print("No")
        return 
    
    ans = [[-1]*size for _ in range(group_num)]

    now = 0
    for i in range(group_num):
        for j in range(size):
            if j<i:
                ans[i][j] = ans[j][i-1]
            else:
                now += 1
                ans[i][j] = now

        
    print("Yes")
    print(group_num)
    for a in ans:
        print(size,*a)

if __name__ == '__main__':
    main()
a,b=map(int,input().split())
n=100

grid=[["#"]*n for _ in range(n//2)]+[["."]*n for _ in range(n//2)]

k=0
cnt=0
for i in range(a-1):
    grid[k][2*i-cnt]="."
    if 2*i==n-2:
        k+=2
        cnt+=n

k=n//2+1
cnt=0
for i in range(b-1):
    grid[k][2*i-cnt]="#"
    if 2*i==n-2:
        k+=2
        cnt+=n
for i in grid:
    print(i)

### FIXED CODE ###

a,b=map(int,input().split())
n=100

grid=[["#"]*n for _ in range(n//2)]+[["."]*n for _ in range(n//2)]

k=0
cnt=0
for i in range(a-1):
    grid[k][2*i-cnt]="."
    if (2*i)%100==n-2:
        k+=2
        cnt+=n

k=n//2+1
cnt=0
for i in range(b-1):
    grid[k][2*i-cnt]="#"
    if (2*i)%100==n-2:
        k+=2
        cnt+=n
print(100,100)
for i in grid:
    print("".join(i))
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = list(list(map(int,input().split())) for i in range(m))

a.sort()
print(a)
t = 0
for i in range(m):
    if sum(a[t:t+bc[i][0]]) < bc[i][0]*bc[i][1]:
        for j in range(bc[i][0]):
            a[t+j] = bc[i][1]
            print(a)
        a.sort()

print(sum(a))


### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = list(list(map(int,input().split())) for i in range(m))

a.sort()
bc.sort(reverse=True,key=lambda x:x[1])
t = 0
for i in range(m):
    for j in range(bc[i][0]):
        if t != n:
            if a[t] < bc[i][1]:
                a[t] = bc[i][1]
                t+=1
            else:
                break
        else:
            break
    else:
        continue
    break

print(sum(a))
N=int(input())
H=list(map(int,input().split()))
num_an=1
tmp=H[0]
for i in range(len(H)-1):
	if tmp>=H[i+1]:
		num_an+=1
	else:
		tmp=H[i+1]
print(num_an)

### FIXED CODE ###

A,B=map(int,input().split())
num_an=0
for i in range(2):
  if A>B:
    num=A
    num_an+=num
    A+=-1
  else:
    num=B
    num_an+=num
    B+=-1
print(num_an)
sys.setrecursionlimit(10**7)

def cur(current,e,dist,color):
    for it in e[current]:
        if color[it]!=-1: continue
        color[it]=(color[current]+dist[(it,current)])%2
        cur(it,e,dist,color)

N=int(input())
e=[[] for i in range(N+1)]
dist={}
for i in range(N-1):
    u,v,w=map(int,input().split())
    e[u].append(v)
    e[v].append(u)
    dist[(u,v)],dist[(v,u)]=w,w
memo=[-1]*N




color=[-1]*(N+1)
color[1]=0
cur(1,e,dist,color)

for i in range(1,N+1):
    print(color[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

def cur(current,e,dist,color):
    for it in e[current]:
        if color[it]!=-1: continue
        color[it]=(color[current]+dist[(it,current)])%2
        cur(it,e,dist,color)

N=int(input())
e=[[] for i in range(N+1)]
dist={}
for i in range(N-1):
    u,v,w=map(int,input().split())
    e[u].append(v)
    e[v].append(u)
    dist[(u,v)],dist[(v,u)]=w,w
memo=[-1]*N




color=[-1]*(N+1)
color[1]=0
cur(1,e,dist,color)

for i in range(1,N+1):
    print(color[i])
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(n):
    if a[i]!=i+1-count:
        count=count+1
if count=0:
    count=-1
print(count)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(n):
    if a[i]!=i+1-count:
        count=count+1
if count==n:
    count=-1
print(count)
#from collections import Counter
N=int(input())
"""F=list(list(map(int,input().split())) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))"""
F=[int(input().replace(' ',''),2)for _ in[0]*N]
P=[list(map(int,input().split()))for _ in[0]*N]
ans=-(1<<40)
for bit in range(1,1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)

### FIXED CODE ###

#from collections import Counter
N=int(input())
F=list(list(map(int,input().split())) for i in range(N))
P=list(list(map(int,input().split())) for i in range(N))
ans=-(1<<40)
for bit in range(1,1<<10):
    tmp = 0
    for i in range(N):
        c=0
        for j in range(10):
            if bit&(1<<j) and F[i][j]:
                c+=1
        tmp+=P[i][c]
    ans = max(ans,tmp)
print(ans)
a, b = map(float, input().split())
print(int(a * b))
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    res = 0
for x in ls:
    res *= x
    if res > 10**18:
        res = -1
print(res)

### FIXED CODE ###

n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    print(0)
    quit()
for x in ls:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)