Harryxun/stf_run huggingface dataset:
N = int(input())
arr = map(int, input().split())
for i in range(n//2, 0, -1): # n // 2 より大きい場合はarrの値そのままでよい。
  arr[i] = sum(arr[i::i]) % 2 # それ以外はパリティをあわせる。
ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)


### FIXED CODE ###

def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    for i in range(n // 2, 0, -1):  # second half: no multiples
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))  # all cells: [1] -> len() (much faster than sum())
    print(*ans)


if __name__ == "__main__":
    main()
a,b=map(int,input().sprit())
if a <=b:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

a,b=map(int,input().split())
if a<=b:
  print("unsafe")
else:
  print("safe")
def main():
    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,
              107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,
              227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283]
    n=int(input())
    if n%2:
        print(*primes[1:n+1])
    else:
        print(*primes[n])

main()


### FIXED CODE ###

def main():
    primes = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491,
              521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031,
              1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511,
              1531]
    n = int(input())
    print(*primes[:n])

main()
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10**9+7
n, *clst = map(int, read().split())
if n == 1:
  print(2*clst[0] % mod)
  quit()
import numpy as np
clst=np.array(clst)
clst=np.sort(clst)
q=np.arange(2**(n-2)+n*2**(n-2),2**(n-1)-1,-2**(n-2))
 
res = np.sum(clst*q)
print(2**n*res % mod)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
mod=10**9+7
n, *clst = map(int, read().split())
if n == 1:
  print(clst[0]*2%mod)
  quit()
clst.sort(reverse=True)
res=sum(i*item for i, item in enumerate(clst,2))
print((4**(n-1)*res)%mod)
x=[]
y=[]
a=i=0
for c in input():
 if"\\"==c:x+=[i]
 elif"/"==c and x:
  j=x.pop()
  t=i-j
  a+=t
  while y and y[-1][0]>j:t+=y[-1][1];y.pop()
  y+=[(j,t)]
 i+=1
print(a)
if p:print(len(y),*list(zip(*y))[1])
else:print(0)


### FIXED CODE ###

A=[]
B=[]
a=0
i=0
for c in input():
 if"\\"==c:
  A+=[i]
 elif"/"==c and A:
  j=A.pop()
  t=i-j
  a+=t
  while B and B[-1][0]>j:
   t+=B[-1][1];B.pop()
  B+=[(j,t)]
 i+=1
print(a)
if B:
 print(len(B),*list(zip(*B))[1])
else:
 print(0)
N, W = list(map(int, input().split()))
WE = []
V = []
for i in range(N):
    w, v = list(map(int, input().split()))
    WE.append(w)
    V.append(v)

# MAX_W = 10 ** 5
MAX_W = 10 ** 9

# DP[i][j]: i以降の品物で重さj以下のときの価値の最大
DP = []
for i in range(N):
    a = [None] * (MAX_W + 1)
    DP.append(a)
DP.append([0] * (MAX_W+1))

for i in range(N-1, -1, -1):
    for j in range(MAX_W+1):
        if i == N:  # i番目の品物はない
            DP[i][j] == 0
        elif j < WE[i]:  # この重さの品物は入れないから無視
            DP[i][j] = DP[i+1][j]
        else:
            DP[i][j] = max(DP[i+1][j], DP[i+1][j-WE[i]]+V[i])

# for i in range(N):
#     print(DP[i][:10])
print(DP[0][W])

### FIXED CODE ###

N, W = list(map(int, input().split()))
WE = []
V = []
INF = float('inf')
for i in range(N):
    w, v = list(map(int, input().split()))
    WE.append(w)
    V.append(v)

MAX_V = (10 ** 3) * 100 + 1

# DP[i+1][j]: i番目までの品物から価値の総和がjとなるように選んだときの、重さの総和の最小値
DP = []
for i in range(N+1):
    a = [INF] * (MAX_V + 1)
    DP.append(a)

DP[0][0] = 0

for i in range(N):
    for j in range(MAX_V):
        if j < V[i]:  # 作りたい価値の総和よりも、価値が大きい
            DP[i+1][j] = DP[i][j]
        else:
            DP[i+1][j] = min(DP[i][j], DP[i][j-V[i]] + WE[i])

r = 0
for i in range(MAX_V+1):
    if DP[N][i] <= W:
        r = i

print(r)

# for i in range(N+1):
    # print(DP[i][:20])
n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []


while len(x) > 2:
  mi = min(x)
  ma = max(x)
  if mi < 0:
    lst.append(str(ma)+" "+str(mi))
    del x[x.index(mi)]
    del x[x.index(ma)]
    x.append(ma - mi)
    lst.append(str(ma)+" "+str(mi))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

print(max(x) - min(x))
for i in range(len(lst)):
  print(lst[i])
print(max(x),min(x))

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
#x = sorted(list(map(int,input().split())),reverse=True)
#nmax = max(x)
#ans = 2*nmax-sum(x)
lst = []

  
nmi = min(x)
nma = max(x)
del x[x.index(nmi)]
del x[x.index(nma)]

mainus = [i for i in x if i < 0]
plus = [i for i in x if i >= 0]
for i in mainus:
  lst.append(str(nma)+" "+str(i))
  nma -= i
for i in plus:
  lst.append(str(nmi)+" "+str(i))
  nmi -= i
lst.append(str(nma)+" "+str(nmi))
print(nma-nmi)
for i in lst:
  print(i)
"""
while max(x) > -1 and len(x) > 1:
  mi = min(x)
  ma = max(x)
  lst.append(str(mi)+" "+str(ma))
  del x[x.index(mi)]
  del x[x.index(ma)]
  x.append(mi - ma)

for i in range(len(x)):
  lst.append(str(nma)+" "+str(i))
  nma += i
print(nmi - nma)
for i in range(len(lst)):
  print(lst[i])
print(nmi,nma)
"""
import itertools
import collections
import numpy as np

N=int(input())
S=list(input())
answer=0
col = collections.Counter(S)
values, counts = zip(*col.most_common())

for i in range(N):
    C=list(itertools.combinations(counts, i+1))
    kumiawase=[np.prod(j) for j in C]
    answer+=sum(kumiawase)
print(answer%(7+10**9))

### FIXED CODE ###

N=list(range(int(input())))
S=list(input())
S=sorted(S)
answer=0

prev=S[0]
counts = []
counter=0

for k in S:
    if k==prev:
        counter+=1
    else:
        prev=k
        if counter!=0:
            counts.append(1+counter)
        counter=1
if counter!=0:
    counts.append(1+counter)

def soujou(li):
    atai=1
    for j in li:
        atai=j*atai
    return atai

answer=soujou(counts)-1
print(answer%(7+10**9))
n=int(input())
x=list(map(int,input().split()))

x.sort()
ans=0

for i range(n):
  ans=ans+x[i*2]
    
print(ans)


### FIXED CODE ###

N = int(input())

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

L.sort()

ans = 0

for i in range(N):
    ans = ans + L[i*2]
    
print(ans)
n, k = map(int,input().split())
a = list(map(int,input().split()))
b = [0] * n

for cnt in range(k):
    if cnt > int(n/2):
        for l in range(n):
            a[l] += k - cnt
        break
    else:
        for i in range(n):
            abl = a[i] * 2 + 1
            for j in range(abl):
                lenge = i - a[i] + j
                if lenge >= 0 and lenge < n:
                    b[lenge] += 1
        a = b
        b = [0] * n

print(*a)

### FIXED CODE ###

s = input()

print(s[:3])
import math
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
flag = 1
if n % 2 == 0:
    start = 1
else:
    if c[0] < 1:
        flag = 0
    start = 2
for i in range(start, n, 2):
    if c[i] != 2:
        flag = 0
        break
if flag == 0:
    print(0)
    exit()
else:
    print(int(math.pow(2, n // 2)))


### FIXED CODE ###

n = int(input())
s = list(map(int, input().split()))
s_set = set(s)
count = 2 ** ((n) // 2)
if (sum(s) == 2 * sum(s_set)):
    print(count % (10 ** 9 + 7))
else:
    print(0)
from bisect import bisect_left as bsl

def main():
    with open(0) as f:
        N, H = map(int, f.readline().split())
        ab = list(map(int, f.read().split()))
    max_slash = max(ab[0::2])
    throw = [x for x in ab[1::2] if x > max_slash]
    throw.sort(reverse=True)
    throw = [sum(throw[0:i]) for i in range(1,len(throw)+1)]
    index = bsl(throw, H)
    l = len(throw)
    if index < l:
        print(index + 1)
    else:
        H += -throw[l-1]
        print(l + (H+max_slash-1)//max_slash)

main()

    

### FIXED CODE ###

N, H = map(int, input().split())
slash = 0
Throw = []
for _ in range(N):
    a, b = map(int, input().split())
    slash = max(slash, a)
    if b > a: Throw.append(b)    
#slash=斬撃最大ダメージ、投げてslash超のダメージが出るならばその剣をダメージが大きい順に投げる
import heapq as hq
Throw = [-th for th in Throw if th > slash]
hq.heapify(Throw)

dmg, cnt = 0, 0
while len(Throw) != 0:
    if dmg >= H: break
    dmg += -hq.heappop(Throw)
    cnt += 1
if dmg < H:
    from math import ceil
    cnt += ceil((H-dmg)/slash)
print(cnt)
# -*- coding: utf-8 -*-

import sys
import os
import math
import itertools

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

for s in sys.stdin:
    n = int(s)

    for i in range(n-1, 3, -1):
        if is_prime(i):
            answer0 = i
            break

    for i in range(n+1, 50000):
        if is_prime(i):
            answer1 = i
            break

    print(answer0, answer1)

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import os
import math
import itertools


def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

for s in sys.stdin:
    n = int(s)

    for i in range(n-1, 0, -1):
        if is_prime(i):
            answer0 = i
            break

    for i in range(n+1, 100000, 1):
        if is_prime(i):
            answer1 = i
            break

    print(answer0, answer1)
import numpy as np
n, m = map(int, input().split())
ab = np.array([list(map(int, input().split())) for x in range(m)]) - 1

to = list(range(n))
ranks = [0] * n
nodes = [1] * n

def find(x):
    if to[x] == x:
        return x
    else:
        root = find(to[x])
        to[x] = root
        return root

entire = (n - 1) * n // 2
def merge(x, y):
    global entire
    xroot = find(x)
    yroot = find(y)
    if xroot == yroot:
        return
    if ranks[xroot] < ranks[yroot]:
        to[xroot] = yroot
        entire -= nodes[yroot] * nodes[xroot]
        nodes[yroot] += nodes[xroot]
    else:
        to[yroot] = xroot
        entire -= nodes[yroot] * nodes[xroot]
        nodes[xroot] += nodes[yroot]
        if ranks[xroot] == ranks[yroot]:
            ranks[yroot] += 1

print(entire)
for a, b in reversed(ab[1:]):
    merge(a, b)
    print(entire)


### FIXED CODE ###

import numpy as np
n, m = map(int, input().split())
ab = np.array([list(map(int, input().split())) for x in range(m)]) - 1

to = list(range(n))
ranks = [0] * n
nodes = [1] * n

def find(x):
    if to[x] == x:
        return x
    else:
        root = find(to[x])
        to[x] = root
        return root

entire = (n - 1) * n // 2
def merge(x, y):
    global entire
    xroot = find(x)
    yroot = find(y)
    if xroot == yroot:
        return
    if ranks[xroot] < ranks[yroot]:
        to[xroot] = yroot
        entire -= nodes[yroot] * nodes[xroot]
        nodes[yroot] += nodes[xroot]
    else:
        to[yroot] = xroot
        entire -= nodes[yroot] * nodes[xroot]
        nodes[xroot] += nodes[yroot]
        if ranks[xroot] == ranks[yroot]:
            ranks[xroot] += 1


results = [entire]
for a, b in reversed(ab[1:]):
    merge(a, b)
    results.append(entire)

for v in reversed(results):
    print(v)
import sys
input = sys.stdin.readline
from math import factorial
large_p = 10**9 + 7

def comb_mod(n, r, large_p):
    a, b = 1, 1
    r = min(r, n - r)
    for i in range(r):
        a = a * (n - i) % large_p
        b = b * (r - i) % large_p
    return a * pow(b, large_p - 2, large_p) % large_p

def main():
    x, y = map(int, input().split())
    p1, p2 = 0, 0
    p1_2, P2_2 = 0, 0
    for i1 in range(1, x//2 + 1):
        if x - i1 == (y - i1 * 2) * 2:
            p1 = i1
            p2 = y - i1 * 2
            break
    for i2 in range(1, y//2 + 1):
        if (x - i2 * 2) * 2 == y - i2:
            p1_2 = i2
            p2_2 = x - i2 * 2

    p1 = min(p1, p1_2)
    p2 = min(p2, p2_2)
    r = comb_mod(p1 + p2, p1, large_p)
    print(r)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
large_p = 10**9 + 7

def comb_mod(n, r, large_p):
    a, b = 1, 1
    r = min(r, n - r)
    for i in range(r):
        a = a * (n - i) % large_p
        b = b * (r - i) % large_p
    return a * pow(b, large_p - 2, large_p) % large_p

def main():
    x, y = map(int, input().split())
    if (x + y) % 3 != 0:
        print(0)
        sys.exit()
    p1, p2 = 0, 0
    for i1 in range(0, x + 1):
        if x - i1 == (y - i1 * 2) * 2:
            p1 = i1
            p2 = y - i1 * 2
            break
    if p1 < 0 or p2 < 0 or (p1 == 0 and p2 == 0):
        print(0)
        sys.exit()

    r = comb_mod(p1 + p2, p1, large_p)
    print(r)

if __name__ == '__main__':
    main()
import fractions

  
def isprime(x):
    count = 1
    for i in range(2,int(x**0.5)+1):
        if x % i == 0:
            count += 1
      
    return count

a,b = map(int,input().split())
g = fractions.gcd(a,b)



ans=0
for i in range(1,int(g**0.5)+1):
    if g % i == 0:
        if isprime(i) == 1:
            ans += 1
        if i != g//i:
            if isprime(g//i) == 1:
                ans += 1
       

print(ans)
  

  

  

  

  


### FIXED CODE ###

n = int(input())
if n%2==0:
  print(1/2)
else:
  print((n//2+1)/n)
#バケット法による解
N = int(input())
dlist = []
for i in range(N):
    dlist.append(int(input()))
dbacket = [0]*100
for d in dlist:
    dbacket[d] += 1
answer = 0
for db in dbacket:
    if db > 0:
        answer += 1
print(answer)

### FIXED CODE ###

day = input()
day = day.replace('2017','2018')
print(day)
a,b,c=map(int,input().split())
import math
ans = 'Yes' if c % math.gcd(a,b) == 0 else 'No'
print(ans)

### FIXED CODE ###

a,b,c=map(int,input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

ans = 'YES' if c % gcd(a,b) == 0 else 'NO'

print(ans)
def degit_sum(n):
    s = list(str(n))
    s = [int(e) for e in s]
    return sum(s)

N = int(input())
degit = len(str(N))
if N % pow(10,degit-1) == 0:
    degit -= 1
A = pow(10,degit-1)
B = N - A
ans = degit_sum(A) + degit_sum(B)
print(ans)

### FIXED CODE ###

N = int(input())
ans = N
for i in range(1,N):
    A,B = 0,0
    A_str = list(str(i))
    B_str = list(str(N-i))
    for e in A_str:
        A += int(e)
    for e in B_str:
        B += int(e)
    if A + B < ans:
        ans = A + B       
print(ans)
s = input()
n = int(input())
i = 0
while s[i]=="1":
    if n==i:
        print(1)
        exit()
    i+=1

for i in range(len(s)):
    if s[i]!="1":
        print(s[i])
        exit()


### FIXED CODE ###

s = input()
n = int(input())
i = 0
while s[i]=="1":
    if n==i+1:
        print(1)
        exit()
    i+=1
    if i==len(s):
        break

for i in range(len(s)):
    if s[i]!="1":
        print(s[i])
        exit()
a, b = input().split()
print (int(a)*int(b) 2*(int(a)+int(b)))


### FIXED CODE ###

#
# 1c
#


def main():
    a, b = map(int, input().split())
    print(a*b, 2*(a+b))


if __name__ == '__main__':
    main()
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,P = inpl()
S = list(map(int,list(input())))

assert 10%P != 0


tmpl = [s*pow(10,N-1-i,P)%P for i,s in enumerate(S)]
xx = [tmpl[0]]
for t in tmpl[1:]:
    xx.append((xx[-1]+t)%P)

yy = [S[0]%P]
for s in S[1:]:
    yy.append((yy[-1]*10+s)%P)

nums = [0]*P
nums[0] += 1
ans = 0
for i,y in enumerate(yy):
    tmp = y*pow(10,N-1-i,P)%P
    ans += nums[tmp]
    nums[xx[i]] += 1


print(ans)


### FIXED CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,P = inpl()
S = list(map(int,list(input())))

if 10%P==0:
    ans= 0
    for i,s in enumerate(S):
        if s%P == 0:
            ans += i+1
    print(ans)
else:
    tmpl = [s*pow(10,N-1-i,P)%P for i,s in enumerate(S)]
    xx = [tmpl[0]]
    for t in tmpl[1:]:
        xx.append((xx[-1]+t)%P)

    yy = [S[0]%P]
    for s in S[1:]:
        yy.append((yy[-1]*10+s)%P)

    nums = [0]*P
    nums[0] += 1
    ans = 0
    for i,y in enumerate(yy):
        tmp = y*pow(10,N-1-i,P)%P
        ans += nums[tmp]
        nums[xx[i]] += 1
    print(ans)
a,b=map(int(input().split()))
print(b%(a+1))

### FIXED CODE ###

a, b = map(int, input().split())
for i in range(50):
    if  a * i  - (i-1) >= b:
        print(i)
        exit()
import numpy as np

s=input()

R=2*s*np.pi
print(R)

### FIXED CODE ###

import numpy as np

s=int(input())

R=2*s*np.pi
print(R)
# coding: utf-8
import sys

def dfs(x, y, fru):
    field[x][y] = '.'
    for dx in [-1,0,1]:
        nx = x + dx
        if 0 <= nx and nx < H and field[nx][y] == fru:
            dfs(nx,y,fru)

    for dy in [-1,0,1]:
        ny = y + dy
        if 0 <= ny and ny < W and field[x][ny] == fru:
            dfs(x,ny,fru)

def solv(H,W):
    count = 0
    for i in range(H):
        for j in range(W):
            if field[i][j] == '@':
                dfs(i,j,'@')
                count+=1
            elif field[i][j] == '#':
                dfs(i,j,'#')
                count+=1
            elif field[i][j] == '*':
                dfs(i,j,'*')
                count+=1
    print(count)

while(True):
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        sys.exit()
    field = []
    for i in range(H):
        field.append(list(input()))
    solv(H,W)

### FIXED CODE ###

# coding: utf-8
# @????????? #?????? *?????????
import sys
sys.setrecursionlimit(10000000)

def dfs(x, y, fru):
    # ???????????¨?????????.???????????????
    field[x][y] = '.'
    # 4??????????????????
    for dx in [-1,0,1]:
        nx = x + dx
        if 0 <= nx and nx < H and field[nx][y] == fru:
            dfs(nx,y,fru)
    for dy in [-1,0,1]:
        ny = y + dy
        if 0 <= ny and ny < W and field[x][ny] == fru:
            dfs(x,ny,fru)

def solv(H,W):
    count = 0
    for i in range(H):
        for j in range(W):
            if field[i][j] != '.':
                dfs(i,j,field[i][j])
                count+=1
            # elif field[i][j] == '#':
            #     dfs(i,j,'#')
            #     count+=1
            # elif field[i][j] == '*':
            #     dfs(i,j,'*')
            #     count+=1
    print(count)

f = 0
while(f == 0):
    H, W = map(int, input().split())
    if H != 0 and W != 0:
        field = [] # ????¨??????¨?????????
        for i in range(H):
            field.append(list(input()))
        solv(H,W)
    else:
        f = 1
a,b = map(int, input().split())

if (a*b)%2 = 1:
  print("Yes")
else:
  print("No")
  


### FIXED CODE ###

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

if (a*b)%2 == 1:
  print("Yes")
else:
  print("No")
r,c = map(int,input().split())
line = []
array = [[0 for i in range(c+1)]for j in range(r+1)]
for i in range(0,r):
    line = input().split()
    for j in range(c):
        array[i][j]=int(line[j])
sum = 0
for i in range(r):
    for j in range(c):
        sum = sum + array[i][j]
    array[i][c]=sum
    sum = 0
for i in range(c):
    for j in range(r):
        sum = sum + array[j][i]
    array[r][i]=sum
    sum = 0
sum = 0
for i in range(c):
    sum = sum + array[r][i]
for j in range(r):
    sum = sum + array[i][c]
array[r][c] = sum    
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print("{}".format(array[i][j])) 
        else:    
            print("{}".format(array[i][j]),end=" ")
       

### FIXED CODE ###

r,c = map(int,input().split())
line = []
array = [[0 for i in range(c+1)]for j in range(r+1)]
for i in range(0,r):
    line = input().split()
    for j in range(c):
        array[i][j]=int(line[j])
sum = 0
for i in range(r):
    for j in range(c):
        sum = sum + array[i][j]
    array[i][c]=sum
    sum = 0
for i in range(c):
    for j in range(r):
        sum = sum + array[j][i]
    array[r][i]=sum
    sum = 0
sum = 0
for j in range(r):
    sum = sum + array[j][c]
array[r][c] = sum    
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print("{}".format(array[i][j])) 
        else:    
            print("{}".format(array[i][j]),end=" ")
n, q = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    g[a].append(b); g[b].append(a)
node = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    node[p] += x

def dfs(v, p=-1):
    for u in g[v]:
        if u==p:
            continue
        node[u] += node[v]
        dfs(u, v)
dfs(0)
print(*node)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

n, q = map(int, input().split())
g = [list() for i in range(n)]
node = [0] * n

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p, x = map(int, input().split())
    node[p-1] += x

def dfs(v, p=-1):
    for u in g[v]:
        if u == p: continue
        node[u] += node[v]
        dfs(u, v)

dfs(0)
print(*node)
def main():
    n,m=map(int,input().split())
    sc=[list(map(int,input().split())) for _ in range(m)]
    a=[0]*(n+1)
    if n==3:
        a[1]=1
    elif n==2:
        a[2]=1
    d=[-1]*(n+1)
    for i in range(m):
        s=sc[i][0]
        c=sc[i][1]
        if d[s]==-1 or a[s]==c:
            a[s]=c
            d[s]=0
        else:
            print(-1)
            return
    ans=100*a[1]+10*a[2]+a[3]
    if ans>=10**(n-1):
        print(ans)
        return
    else:
        print(-1)
        return
main()

### FIXED CODE ###

n,m=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(m)]
a=[0]*(n+1)
if n!=1:
    a[1]=1
d=[-1]*(n+1)
flg=True
for i in range(m):
    s=sc[i][0]
    c=sc[i][1]
    if d[s]==-1 or a[s]==c:
        a[s]=c
        d[s]=0
    else:
        flg=False
ans=int("".join(map(str,a)))
if ans>=10**(n-1) and flg:
    print(ans)
elif n==1 and ans==0:
    print(ans)
else:
    print(-1)
import sys

N = int(input())

a = input()
b = input()

for i in range(N):
	if(a[0:N-i] == b[i:N]){
		print(N+i)
		sys.exit()
		
print(2 * N)

### FIXED CODE ###

import sys

N = int(input())

a = input()
b = input()

for i in range(N):
	if a[i:N] == b[0:N-i]:
		print(N+i)
		sys.exit()
		
print(2 * N)
n = int(input())
a = set(int(input()) for i in range(n))
kami = []
a.sort()
for i in range(n) :
    if i in kami :
        kami.remove(i)
    else :
        kami.add(i)

print(len(kami))


### FIXED CODE ###

n = int(input())
kami = set()

for i in range(n) :
    a = int(input())
    if a in kami :
        kami.remove(a)
    else :
        kami.add(a)

print(len(kami))