Harryxun/stf_run huggingface dataset:
d=int(input())
if d==25:
    print('Christmas')
elif d==24:
    pirnt('Christmas Eve')
elif d==23:
    print('Christmas Eve Eve')
elif d==22:
    print('Christmas Eve Eve Eve')

### FIXED CODE ###

d=int(input())
if d==25:
    print('Christmas')
elif d==24:
    print('Christmas Eve')
elif d==23:
    print('Christmas Eve Eve')
elif d==22:
    print('Christmas Eve Eve Eve')
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(int(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print(*stack)
        

### FIXED CODE ###

import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element in func:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
        else:
            stack.append(float(element))
    print('{:.6f}'.format(stack[0]))
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
n,x=map(int,input().split())
l=[int(i) for i in input().split()]
print(reduce(math.gcd,[abs(i-x) for i in l]))


### FIXED CODE ###

import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n,x=map(int,input().split())
l=[int(i) for i in input().split()]
print(gcd_list([abs(i-x) for i in l]))
[a, b] = [int(x) for x in input().split()]

if a < b:
    print(int(a) + '<' + int(b))
elif a > b:
    print(int(a) + '>' + int(b))
else:
    print(int(a) + '=='+ int(b))

### FIXED CODE ###

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

if a < b:
    print('a < b')
elif a > b:
    print('a > b')
else:
    print('a == b')
A,op,B=input().split()

if op=='+':
  print(int(A)+int(B))
else:
  print(int(-A)-int(B))

### FIXED CODE ###

A,op,B=input().split()

if op=='+':
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_li = [0]
a_ = 0
b_li = [0]
b_ = 0

for A_ in A:
    a_ = a_ + A_
    a_li.append(a_)

for B_ in B:
    b_ = b_ + B_
    b_li.append(b_)

book_max = 0
book_cnt_a = 0
book_cnt_ab = 0

for a_ in a_li:
    book_cnt_ab = M
    for b_ in b_li.reverse():
        if (a_ + b_) < K:
            if (book_max <= book_cnt_ab + book_cnt_a):
                book_max = book_cnt_ab + book_cnt_a
            break
        book_cnt_ab = book_cnt_ab - 1
    book_cnt_a = book_cnt_a + 1

print(book_max)


### FIXED CODE ###

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

Asum_li = [0]
Asum = 0
Bsum_li = [0]
Bsum = 0

for A_ in A:
    Asum = Asum + A_
    Asum_li.append(Asum)

for B_ in B:
    Bsum = Bsum + B_
    Bsum_li.append(Bsum)

cnt_max = 0
cnt_b = M

for cnt_a in range(N+1):

    if Asum_li[cnt_a] > K : break

    while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:
        cnt_b = cnt_b - 1
        if cnt_b < 0: break

    if (cnt_max < cnt_a + cnt_b): cnt_max = cnt_a + cnt_b


print(cnt_max)
n,m = map(int,input().split())
if n == m:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

n,m = map(int,input().split())
if n == m:
  print('Yes')
else:
  print('No')
[A,B,C,N]=[int(i) for i in input().split()]
[C,B,A]=[A,B,C].sort()
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C=0:cnt+=1
print(cnt)

### FIXED CODE ###

[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A+1):
  k=N-(i*A)
  for j in range(k//B+1):
    if (k-(B*j))%C==0:
    	cnt+=1
print(cnt)
n = int(input())
x = input()

f = [-1] * (n+10)
f[0] = 0

for i in range(1, n+10):
    # python bitcount で見つけたこれを参考に https://ameblo.jp/316228/entry-10518720149.html
    f[i] = f[i % bin(i).count('1')] + 1

init_bitcount = x.count('1')
# Xを init_bitcount+1とinit_bitcount-1で割った余り

x_mod_01 = 0
x_mod_10 = 0
for digit in x:
    x_mod_01 *= 2
    x_mod_10 *= 2
    if digit == '1':
        x_mod_01 += 1
        x_mod_10 += 1
    x_mod_01 %= (init_bitcount+1)
    x_mod_10 %= (init_bitcount-1)

# print(x_mod_01, x_mod_10, init_bitcount)

for i in range(n):
    if x[i] == '0':
        # 0→1
        first_residue = (x_mod_01 + 2**(n - i - 1)) % (init_bitcount+1)
        print(f[first_residue] + 1)
    else:
        # 1→0
        first_residue = (x_mod_10 - 2**(n - i - 1)) % (init_bitcount-1)
        print(f[first_residue] + 1)


### FIXED CODE ###

n = int(input())
x = input()

f = [-1] * (n+10)
f[0] = 0

for i in range(1, n+10):
    # python bitcount で見つけたこれを参考に https://ameblo.jp/316228/entry-10518720149.html
    f[i] = f[i % bin(i).count('1')] + 1

init_bitcount = x.count('1')
# Xを init_bitcount+1とinit_bitcount-1で割った余り

x_mod_01 = 0
x_mod_10 = 0
for digit in x:
    x_mod_01 *= 2
    x_mod_10 *= 2
    if digit == '1':
        x_mod_01 += 1
        x_mod_10 += 1
    x_mod_01 %= (init_bitcount+1)
    if init_bitcount != 1:
        x_mod_10 %= (init_bitcount-1)

# print(x_mod_01, x_mod_10, init_bitcount)

power_mod_01 = [-1] * (n+10)
power_mod_01[0] = 1
for i in range(1, n+10):
    power_mod_01[i] = power_mod_01[i-1] * 2 % (init_bitcount + 1)

if init_bitcount != 1:
    power_mod_10 = [-1] * (n+10)
    power_mod_10[0] = 1
    for i in range(1, n+10):
        power_mod_10[i] = power_mod_10[i-1] * 2 % (init_bitcount - 1)


for i in range(n):
    if x[i] == '0':
        # 0→1
        first_residue = (x_mod_01 + power_mod_01[n - i - 1]) % (init_bitcount+1)
        print(f[first_residue] + 1)
    else:
        if init_bitcount == 1:
            print(0)
            continue
        # 1→0
        first_residue = (x_mod_10 - power_mod_10[n - i - 1]) % (init_bitcount-1)
        print(f[first_residue] + 1)
import sys

def add_count(addnum, relations, counters, nodelist):
  new_nodelist = []
  for node in nodelist:
    if node not in relations:
      continue
    else:
      new_nodelist = new_nodelist + relations[node]
      for child in relations[node]:
        counters[child-1] += addnum
  
  if len(new_nodelist) == 0:
    return counters
  else:
    return add_count(addnum, relations, counters, new_nodelist)

N, Q = map(int, sys.stdin.readline().split())
alist = list(list(map(int, sys.stdin.readline().split())) for i in range(N-1))
qlist = list(list(map(int, sys.stdin.readline().split())) for i in range(Q))

counters = [0 for i in range(N)]
relations = {}
for a in alist:
  if a[0] not in relations:
    relations[a[0]] = [a[1]]
  else:
    relations[a[0]].append(a[1])

for q in qlist:
  counters[q[0]-1] += q[1]
  if q[0] in relations:
    counters = add_count(q[1], relations, counters, [q[0]])

print(' '.join(map(str,counters)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input=lambda :sys.stdin.readline()

def sol():

  N,Q = map(int,input().split())
  graph = [[] for i in range(N)]
  ans = [0 for i in range(N)]
  for _ in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

  for _ in range(Q):
    p, x = map(int,input().split())
    ans[p-1] += x 
 
  def dfs(v,p=-1):
    for u in graph[v]:
      if u == p: continue
      ans[u] += ans[v]
      dfs(u,v)
  dfs(0)
  print(*ans)

sol()
s=list(map(int,input().split()))
print(sum(l)-max(l))

### FIXED CODE ###

l=list(map(int,input().split()))
print(sum(l)-max(l))
import sys
import numpy as np
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

h,w,k = LI()
cnt = 0
c = [0]*h
for i in range(h):
    c[i] = input()

for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(w):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == k:
            cnt += 1
print(cnt)

### FIXED CODE ###

import sys
import numpy as np
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

h,w,k = LI()
cnt = 0
c = [0]*h
for i in range(h):
    c[i] = input()

for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(w):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == k:
            cnt += 1
print(cnt)
print(int(input())*6.3)


### FIXED CODE ###

r=int(input())
print(2*3.14*r)
import numpy as np
 
N = int(input())
P = np.array(input().split(' '), dtype = int)
 
counta = 0
for i in range(N):
    if np.sum((P >= P[i])[:i+1]) == i + 1:
        counta += 1
print(counta)

### FIXED CODE ###

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = list(map(int, input().split(' ')))

p_min = P[0]
ans = 0
for p in P:
    if p <= p_min:
        p_min = p
        ans += 1
print(ans)
import sys

a, b, c, d = map(int, sys.stdin.readline().split())
print(min(a,b) + min(c,d))

### FIXED CODE ###

import sys

a, b, c, d = [int(input()) for _ in range(4)]

print(min(a,b) + min(c,d))
a, b = map(int,input().split())
 
if 1 <= a =<9 and 1 <= b <=9:
    print(a*b)
else:
    print(-1)

### FIXED CODE ###

a, b = map(int,input().split())
if 1 <= a <= 9 and 1 <= b <= 9:
    print(a*b)
else:
    print(-1)
from math import gcd
from math import ceil

a, b = 1, 1
for _ in range(int(input())):
  x, y = map(int, input().split())
  k = int(max(math.ceil(x / a), math.ceil(y / b)))
  a = x * k
  b = y * k
print(a + b)


### FIXED CODE ###

a, b = 1, 1
for _ in range(int(input())):
  x, y = map(int, input().split())
  k = max((a + x - 1) // x, (b + y - 1) // y)
  a = x * k
  b = y * k
print(a + b)
H=int(input())
a=1
ans=1
while True:
  if a>H:
    break
   ans=ans+a
  a=a*2

print(ans)

### FIXED CODE ###

H=int(input())
a=1
ans=0
while True:
  if a>H:
    break
  ans=ans+a
  a=a*2
 
print(ans)
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]:
        print('-1')
        sys.exit()
    elif x[0] == '1' and x[1] == '0':
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if b[0] == '0' and b[1] != '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)


### FIXED CODE ###

import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]: #既に与えられたところに違う値
        print('-1')
        sys.exit()
    elif N >= 2 and x[0] == '1' and x[1] == '0': #the first digit is  "0"
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if N != 1 and b[0] == '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)
N = int(input())
D,X = map(int,input().split())
count = x

for i in range(N):
  a = int(input())
  count+=1+((D-1)//a)

print(count)



### FIXED CODE ###

N = int(input())
D,X = map(int,input().split())
count = X

for i in range(N):
  a = int(input())
  count+=1+((D-1)//a)

print(count)
# -*- coding: UTF-8 -*-
L, N = map(int, input().split())
a = [input() for i in range(N)]
a.sort()
b = "".join(a)
print(b)

### FIXED CODE ###

# -*- coding: UTF-8 -*-
N, L = map(int, input().split())
a = [input() for i in range(N)]
a.sort()
b = "".join(a)
print(b)
a=input()
s=int(a)
if s<86400 and s>=0:

    h=int(s/3600)
    m=int((s-h*3600)/60)
    s=s-h*3600-m*60
    print("{0}:{1}:{2}".format(h,m,s))

else:
    exit(

### FIXED CODE ###

a=input()
s=int(a)
if s<86400 and s>=0:

    h=int(s/3600)
    m=int((s-h*3600)/60)
    s=s-h*3600-m*60
    print("{0}:{1}:{2}".format(h,m,s))

else:
    exit()
N = int(input())
S = input()

cnt = 0

for i in range(1000):
    if 0 <= i < 10:
        a = "00" + str(i)
    elif 10 <= i < 100:
        a = "0" + str(i)
    elif 100 <= i:
        a = str(i)
    
    idx = 0
    for j in range(S):
        if S[i] == a[idx]:
            idx += 1
            if idx == 3:
                cnt += 1
                break

print(cnt)

### FIXED CODE ###

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

cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            pin = [i, j, k]
            x = 0

            for a in S:
                if a == pin[x]:
                    x += 1
                    if x == 3:
                        cnt += 1
                        break

print(cnt)
InputData=[]
while True:
    try:
        in1,in2 = map(int,raw_input().split(" "))  # Python2
        if in1==0 and in2==0 : break
        InputData.append([in1,in2])
    except EOFError:
        break

for i in range(len(InputData)):
    in1,in2 = InputData[i]
    x = int(in1) * int(in2)
	y = int(in1) + int(in2) + int(in1) + int(in2)
	)
    print(x y)

### FIXED CODE ###

InputData=[]
while True:
    try:
        in1,in2 = map(int,raw_input().split(" "))  # Python2
        if in1==0 and in2==0 : break
        InputData.append([in1,in2])
    except EOFError:
        break

for i in range(len(InputData)):
    in1,in2 = InputData[i]
    x = int(in1) * int(in2)
    y = (int(in1) + int(in2)) * 2
    print(str(x) + " " + str(y))
import collections
import sys

N = int(input())
a = list(map(int,input().split()))
a = collections.Counter(a)

value, count = list(a.keys()), list(a.values())

if sum(a)==0:
    print('Yes')
    sys.exit()

elif len(value)<2:
    print('No')
    sys.exit()

elif count[0]+count[1]+count[2] != N:
    print('No')

elif value[0]^value[1]^value[2] != 0:
    print('No')

elif count[0]==count[1]==count[2]:
    print('Yes')

else:
    print('No')


### FIXED CODE ###

import collections

N = int(input())
a = list(map(int,input().split()))
a = collections.Counter(a)

value, count = list(a.keys()), list(a.values())

if len(value)<3:
    if len(value)==1:
        if sum(a)==0:
            print('Yes')
        else:
            print('No')

    if len(value)==2:
        if 0 in value:
            if count[0]==N/3 or count[1]==N/3:
                print('Yes')
            else:
                print('No')

        else:
            print('No')

if len(value)>=3:
    if count[0]+count[1]+count[2] == N:
        if value[0]^value[1]^value[2] == 0:
            if count[0]==count[1]==count[2]:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
#-*-coding:utf-8-*-

def main():
    n = int(input())
    a_list = list(set(list(map(int, input().split()))))
    b_list = list(set(list(map(int, input().split()))))
    c_list = list(set(list(map(int, input().split()))))

    a_list.sort()
    b_list.sort()
    c_list.sort()

    cnt = 0

    for i in range(n):
        for j in range(n):
            if a_list[i] < b_list[j]:
                for k in range(n):
                    if b_list[j] < c_list[k]:
                        cnt += n - k
                        break
    
    print(cnt)


if __name__ == '__main__':
    main()

### FIXED CODE ###

#-*-coding:utf-8-*-
import bisect

def main():

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    c_list = list(map(int, input().split()))

    a_list.sort()
    b_list.sort()
    c_list.sort()

    cnt = 0
    
    for b in b_list:
        i = bisect.bisect_left(a_list, b)
        j = n - bisect.bisect_right(c_list, b)
        cnt += i * j
    
    print(cnt)
    
if __name__ == '__main__':
    main()
n = list(map(int,input().split(' ')))
ans = i if n.count(i)==1 for i in list(dict.fromkeys(n))
print(str(ans))

### FIXED CODE ###

n = list(map(int,input().split(' ')))
print(str(max([i if n.count(i)==1 else -10000 for i in list(dict.fromkeys(n))])))
from collections import deque

f = open("C:/Users/naoki/Desktop/Atcoder/input.txt") 

n = int(f.readline())
p = list(map(int, f.readline().split()))
for i in range(len(p)):
    p[i] -= 1

to_outsides = [[0 for _ in range(n)] for _ in range(n)]
not_exist = [["■" for _ in range(n)] for _ in range(n)]


for i in range(n):
    for j in range(n):
        to_outside = [i,n-1-i,j,n-1-j]
        to_outsides[i][j] = min(to_outside)

directions = [[-1,0],[1,0],[0,-1],[0,1]]


all_loss = 0
answer = 0
for i, person in enumerate(p):
    
    exited = [person//n, person%n]
    answer += to_outsides[exited[0]][exited[1]]
    not_exist[exited[0]][exited[1]] = "□"
    seen = [[False for _ in range(n)] for _ in range(n)]
    seen[exited[0]][exited[1]]=True
    todo = deque([exited])
    renews = []
    while len(todo)>0:
        now = todo.pop()
        renews.append(now)
        for direction in directions:
            try:
                checking = [now[0]+direction[0],now[1]+direction[1]]
                to_outsides[checking[0]][checking[1]]
            except:
                continue
            if seen[checking[0]][checking[1]] == False and\
            ((not_exist[checking[0]][checking[1]] == "□" and  to_outsides[checking[0]][checking[1]]==to_outsides[now[0]][now[1]])or\
            to_outsides[checking[0]][checking[1]]>to_outsides[now[0]][now[1]]):
                todo.append([checking[0],checking[1]])
                seen[checking[0]][checking[1]] = True
    to_outsides_pre = to_outsides.copy()
    for renew in renews:
        if to_outsides[renew[0]][renew[1]] != 0:
            to_outsides[renew[0]][renew[1]]-=1
print(answer)

### FIXED CODE ###

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

dp = [[min(i, N - i - 1, j, N - j - 1) for j in range(N)] for i in range(N)]

presence = [[1 for j in range(N)] for i in range(N)]

ans = 0
for i in range(len(P)):
    P[i] -= 1
    x, y = divmod(P[i], N)
    ans += dp[x][y]
    presence[x][y] = 0

    Q = [(x, y)]
    #%%
    while Q:
        x, y = Q.pop()
        new_value = dp[x][y] + presence[x][y]
        if 1 <= x and dp[x - 1][y] > new_value:
            dp[x - 1][y] = new_value
            Q.append((x - 1, y))
        if x < N - 1 and dp[x + 1][y] > new_value:
            dp[x + 1][y] = new_value
            Q.append((x + 1, y))
        if 1 <= y and dp[x][y - 1] > new_value:
            dp[x][y - 1] = new_value
            Q.append((x, y - 1))
        if y < N - 1 and dp[x][y + 1] > new_value:
            dp[x][y + 1] = new_value
            Q.append((x, y + 1))

print(ans)
#!/usr/bin/env python
#coding:utf-8

def input_strs():
    return input().split(" ")

def input_nums():
    return [int(i) for i in input_strs()]


w = input()
ok = True
h = Map()

for i in w:
    h[i] = h.get(i, 0) + 1

for key in h:
    ok = ok and (h[key] % 2 == 0)
if ok:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

def input_strs():
    return input().split(" ")

def input_nums():
    return [int(i) for i in input_strs()]


w = input()
ok = True

for c in w:
    p = 0
    for k in w:
        if c == k:
            p += 1
    ok = ok and (p % 2 == 0)

if ok:
    print("Yes")
else:
    print("No")
x=int(input(""))
y=int(input(""))
z=int(input(""))
answer= (x-z)//(z+y)
print(answer)
exit()

### FIXED CODE ###

x,y,z=map(int,input().split())
print((x-z)//(y+z))
from collections import defaultdict

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N-1)]

d = defaultdict(list)
class Tree:
    def __init__(self, v):
        self.v = v
        self.neighbors = []

    def set_rank(self,rank,parent):
        self.rank = rank
        for neighbor in self.neighbors:
            if neighbor == parent:
                continue
            neighbor.set_rank(rank=rank+1,parent=self)



trees = {i:Tree(i) for i in range(1,N+1)}

for a,b in AB:
    trees[a].neighbors.append(trees[b])
    trees[b].neighbors.append(trees[a])
trees[1].set_rank(1,None)

group0 = [node.v for node in  trees.values() if node.rank %2 ==0]
group1 = [node.v for node in  trees.values() if node.rank %2]
x = [set(),set(),set()]
for i in range(1,N+1):
    x[i%3].add(i)
if len(group1) < len(group0):
    group1,group0 = group0,group1

result = {}
if len(group0) <= len(x[0]):
    while group0:
        result[group0.pop()]= x[0].pop()
    y = x[0]|x[1]|x[2]
    while group1:
        result[group1.pop()] = y.pop()
else:
    while x[2] and group0:
        result[group0.pop()] = x[2].pop()
    while x[1] and group1:
        result[group1.pop()] = x[1].pop()
    while group0:
        result[group0.pop()] = x[0].pop()
    while group1:
        result[group1.pop()] = x[0].pop()

print(' '.join(str(result[i]) for i in range(1,N+1)))



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N - 1)]


class Tree:
    def __init__(self, v):
        self.v = v
        self.neighbors = []

    def set_rank(self, rank, parent):
        self.rank = rank
        for neighbor in self.neighbors:
            if neighbor is parent:
                continue
            neighbor.set_rank(rank=rank + 1, parent=self)


trees = {i: Tree(i) for i in range(1, N + 1)}

for a, b in AB:
    trees[a].neighbors.append(trees[b])
    trees[b].neighbors.append(trees[a])
try:
    trees[1].set_rank(1, None)
except:
    print(-1)
    exit()

group0 = [node.v for node in trees.values() if node.rank % 2 == 0]
group1 = [node.v for node in trees.values() if node.rank % 2]
x = [set(), set(), set()]
for i in range(1, N + 1):
    x[i % 3].add(i)
if len(group1) < len(group0):
    group1, group0 = group0, group1
result = {}
if len(group0) <= len(x[0]):
    while group0 and x[0]:
        result[group0.pop()] = x[0].pop()
    y = x[0] | x[1] | x[2]
    while group1 and y:
        result[group1.pop()] = y.pop()
else:
    while x[2] and group0:
        result[group0.pop()] = x[2].pop()
    while x[1] and group1:
        result[group1.pop()] = x[1].pop()
    while group0 and x[0]:
        result[group0.pop()] = x[0].pop()
    while group1 and x[0]:
        result[group1.pop()] = x[0].pop()
    if group0 or group1:
        print(-1)
        exit()

print(' '.join(str(result[i]) for i in range(1, N + 1)))
import sys
 
sys.setrecursionlimit(int(1e6))
 
 
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
 
    def get_sum(self, i):
        ret = 0
        while i > 0:
            ret += self.data[i]
            i -= (i & -i)
        return ret
 
    def add(self, i, w):
        if i == 0:
            return
        while i <= self.n:
            self.data[i] += w
            i += (i & -i)
 
 
def dfs(u, cnt):
    cnt += 1
    l[u] = cnt
    for c in tree[u]:
        cnt = dfs(c, cnt)
    cnt += 1
    r[u] = cnt
    return cnt
 
 
n = int(input())
l, r = [0] * n, [0] * n
tree = [set(map(int, input().split()[1:])) for _ in range(n)]
 
bit = BIT(dfs(0, 1))
 
q = int(input())
for _ in range(q):
    line = list(map(int, input().split()))
    if line[0]:
        print(bit.get_sum(r[line[1]] - 1))
    else:
        bit.add(l[line[1]], line[2])
        bit.add(r[line[1]], -line[2])


### FIXED CODE ###

import sys

sys.setrecursionlimit(int(1e6))


class BIT:
	def __init__(self, n):
		self.n = n
		self.data = [0] * (n + 1)

	def get_sum(self, i):
		ret = 0
		while i > 0:
			ret += self.data[i]
			i -= (i & -i)
		return ret

	def add(self, i, w):
		if i == 0:
			return
		while i <= self.n:
			self.data[i] += w
			i += (i & -i)

def dfs(u, cnt):
	cnt += 1
	l[u] = cnt
	for c in tree[u]:
		cnt = dfs(c, cnt)
	cnt += 1
	r[u] = cnt
	return cnt

n = int(input())
l, r = [0] * n, [0] * n
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

bit = BIT(dfs(0, 1))

q = int(input())
for _ in range(q):
	line = list(map(int, input().split()))
	if line[0]:
		print(bit.get_sum(r[line[1]] - 1))
	else:
		bit.add(l[line[1]], line[2])
		bit.add(r[line[1]], -line[2])