Harryxun/stf_run huggingface dataset:
s = input()
if s == "KIHBR" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or s == "AKIHABR" or s == "AKIHBAR"or s == "AKIHBRA"or s == "KIHABAR"or s == "KIHABRA"or s == "KIHBARA"or s == "AKIHABAR"or s == "AKIHABRA"or s == "AKIHBARA"or s == "KIHABARA"or s == "AKIHABARA":
    print("YWS")
else:
    print("NO)

### FIXED CODE ###

s = input()
if s == "KIHBR" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or s == "AKIHABR" or s == "AKIHBAR"or s == "AKIHBRA"or s == "KIHABAR"or s == "KIHABRA"or s == "KIHBARA"or s == "AKIHABAR"or s == "AKIHABRA"or s == "AKIHBARA"or s == "KIHABARA"or s == "AKIHABARA":
    print("YES")
else:
    print("NO")
def main():
    with open('sample.txt') as f:
        ab, bc, ca = [int(x) for x in f.readline().rstrip().split()]
        print(ab * bc // 2)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin


def main():
    ab, bc, ca = [int(x) for x in stdin.readline().rstrip().split()]
    print(ab * bc // 2)


if __name__ == "__main__":
    main()
n, d = map(int, input().split())
i = 0
num = 0
while i < n:
  x, y = map(int, input().split())
  _d = sqrt((x*x) + (y*y))
  if _d <= d:
    num += 1
  i += 1
 
print(num)

### FIXED CODE ###

import math
# -*- coding: utf-8 -*-
n, d = map(int, input().split())
i = 0
num = 0
while i < n:
  x, y = map(int, input().split())
  _d = math.sqrt((x*x) + (y*y))
  if _d <= d:
    num += 1
  i += 1
 
print(num)
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
A = IR(m)
dp = [0]*(n+3)
dp[0] = 1

A.sort(reverse=True)
tmp = A.pop()
if tmp == 1:
    dp[1] = 0
    if len(A) > 0:
        tmp = A.pop()
else:
    dp[1] = 1

for i in range(n+1):
    if tmp == i+2:
        dp[i+2] = 0
        if len(A) > 0:
            tmp = A.pop()
    else:
        dp[i+2] += dp[i+1] + dp[i]

print(dp[n] % MOD)


### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
A = IR(m)
dp = [0]*(n+3)
dp[0] = 1

A.sort(reverse=True)
if len(A) > 0:
    tmp = A.pop()
else:
    tmp = -1
if tmp == 1:
    dp[1] = 0
    if len(A) > 0:
        tmp = A.pop()
else:
    dp[1] = 1

for i in range(n+1):
    if tmp == i+2:
        dp[i+2] = 0
        if len(A) > 0:
            tmp = A.pop()
    else:
        dp[i+2] += dp[i+1] + dp[i]

print(dp[n] % MOD)
import sys
X, N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()
  
if X == 100 and N == 100:
  print(-100)
  sys.exit()
  
  
P = list(map(int, input().split()))

lis = []
for i in range (-100,102,1):
    if i not in P:
        lis.append(i)


        
        
        
ans = 10**18
suzi = 0
lis2 = []
for j in lis:
    num = abs(X-j)
    if num < ans:
        ans = num
        suzi = j

print(suzi)

    


### FIXED CODE ###

X1,X2,X3,X4,X5 = map(int, input().split())
lis = [X1,X2,X3,X4,X5]

for i in range(len(lis)):
    if lis[i] == 0:
        print(i+1)
N,M = map(int,input().split(' '))
l = [int(input()) for i in range(M)]

pre = 0
last = -1
ans_l = []
flag = False
l.append(N+1)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in l:
    if i==1:
        last = 1
        continue
    if i-last==1:
        flag =True
        break
    n = i - last - 3
    r = 0
    tmp = 1
    dif = 1
    # print("n",n)
    while dif>0:
        r += 1
        tmp += cmb(n, r)
        dif = n-r
        n -= 1
        # print("tmp",tmp,n,r)
    ans_l.append(tmp)
    # print(i,ans_l)
    last = i
if flag:
    print(0)
else:
    ans = 1
    for i in ans_l:
        ans*=i
    print(ans%1000000007)

### FIXED CODE ###

N,M = map(int,input().split(' '))
l = set([int(input()) for i in range(M)])

mod = 10**9+7
dp = {}
for i in range(N+1):
    dp[i] = 1
dp[1] = 0 if 1 in l else 1

for i in range(2,N+1):
    if i in l:
        dp[i] = 0
        continue
    else:
        dp[i] = dp[i-1]%mod + dp[i-2]%mod
        dp[i] = dp[i]%mod

print(dp[N]%mod)
def main():
    d = int(input())
    c = [-1] + list(map(int,input().split()))
    s = [0] * (d+1)
    last = [-1] + [0] * d
    for i in range(1,d+1):
        s[i] = [0] + list(map(int,input().split()))

    for i in range(1,d+1):
        mx = max(s[i])
        mx_ind = s.index(mx)
        print(mx_ind)



if __name__ == '__main__':
    main()


### FIXED CODE ###



def main():

    for i in range(365):
        print(10)


if __name__ == '__main__':
    main()
N,M=map(int,input().split())
A = []

if M != 0:
  for _ in range(M):
    A.append(int(input()))

#初期化
dp=[0]*N
if A.count(1) == 0:
  dp[0]=1
if A.count(1) == 0 and A.count(2) == 0:
  dp[1]=2
elif A.count(1) ==1 and A.count(2) ==0:
  dp[1]=1

#dp
if N >= 3:
  for i in range(N-2):
    if A.count(i+3) ==1:
      dp[i+2] = 0
    elif A.count(i+1) == 0 and A.count(i+2) == 0:
      dp[i+2] = dp[i+1] + dp[i]
    elif A.count(i+1) == 0 and A.count(i+2) == 1:
      dp[i+2] = dp[i]
    elif A.count(i+1) == 1 and A.count(i+2) == 0:
      dp[i+2] = dp[i+1]
    else:
      dp[i+2] = 0
      
print(dp[N-1]%1000000007)

### FIXED CODE ###

N,M=map(int,input().split())
A = [0]*(N+1)

for _ in range(M):
  a = int(input())
  A[a] = 1

#初期化
dp=[0]*(N+1)
dp[0] = 1
if A[1] == 0:
  dp[1] = 1

#dp
for i in range(2,N+1):
  if A[i] == 0:
    dp[i] = dp[i-1] + dp[i-2]
      
print(dp[N]%1000000007)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
	search(values,hp-1,vp,item)
	search(values,hp+1,vp,item)
	search(values,hp,vp-1,item)
	search(values,hp,vp+1,item)

def solve(values):
	count=0
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in ['@','#','*']:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line,values=input(),list()
	while line!='0 0':
		H,W = list(map(int,line.strip().split(' ')))
		value = list()
		for _ in range(H):
			value.append(list(x for x in input().strip()))
		values.append(value)
		line = input()
	for value in values:
		print(solve(value))

if __name__=='__main__':
	main()

### FIXED CODE ###

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

import sys
sys.setrecursionlimit(10**6)

def search(field,hp,vp,item):
	if not (0<=hp<len(field)): return
	if not (0<=vp<len(field[hp])): return
	if item!=field[hp][vp]: return
	field[hp][vp]=True
	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
		search(field,hp+dh,vp+dv,item)
#	search(field,hp-1,vp,item)
#	search(field,hp+1,vp,item)
#	search(field,hp,vp-1,item)
#	search(field,hp,vp+1,item)

def solve(field):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(field)):
		for j in range(len(field[i])):
			if field[i][j] in valid_items:
				search(field,i,j,field[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		field = list()
		for _ in range(H):
			field.append(list(input().strip()))
		print(solve(field))
		line = input().strip()

if __name__=='__main__':
	main()
a, b = input().split()
a = int(a)
b = math.floor(float(b) * 100)
print(a * b // 100)

### FIXED CODE ###

import math


def main():
    a, b = input().split()
    A = int(a)
    # B = int(math.floor(float(b) * 100))
    B = int(b.replace('.', ''))
    print(int(A * B // 100))


if __name__ == '__main__':
    main()
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0
y = True

for i in range(n):
    if x[0] != x[i]:
        y = False

if y:
    print(0)
    exit(0)

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)

### FIXED CODE ###

n,r = map(int,input().split())
if n >= 10:
    print(r)
else:
    k = 10 - n
    print(100 * k + r)
N,A,B,C,D=list(map(int,input().split()))
S=input()
bS=S[B-1:D-1]
a=True
if C<D:
    if "##" in bS:
        a=False
    else:
        S=S[:D-1]+"#"+S[D-1:]
        aS=S[A-1:C-1]
        if "##" in aS:
            a=False

else:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C-1]
        if "##" in aS:
            a=False
        else:
            if (not "..." in bS) and (aS[D]=="#" or aS[D-2]=="#"):
                a=False
            
        
        
if a:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N,A,B,C,D=list(map(int,input().split()))
S=input()
bS=S[B-1:D]
a=True
if C<D:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C]
        if "##" in aS:
            a=False

else:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C]
        if "##" in aS:
            a=False
        else:
            tmp=S[:B-1]+"#"+S[B:]
            aS=tmp[A-1:C]
            j1= ("##" in aS)
            tmp=S[:D-1]+"#"+S[D:]
            aS=tmp[A-1:C]
            j2= ("##" in aS)
            if  ((not "..." in bS) and (j1 and j2)):
                a=False
            
        
        
if a:
    print("Yes")
else:
    print("No")
i = int(input())
s = input()
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
ans = [en[(en.index(x) + 26) % 26 + i] for x in s]
print(ans.join(''))

### FIXED CODE ###

i= int(input())
s = input()
en = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
s_list = [(en[(en.index(k)+i)%26]) for k in s]
print(''.join(s_list))
N,K = map(int,input().split())
p = list(map(int,input().split()))

expect_value = [0]*N

for i in range(N):
    expect_value[i] = ((p[i] * (p[i]+1))/2) * (1/p[i])

ans = [0] * (N - K + 1))
for i in range(N - K + 1):
    ans[i] = sum(expect_value[i:i+K])
print(max(ans)

### FIXED CODE ###

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


def cal_expect(value):
    return ((value*(value+1))/2)*(1/value)

expect_value = [0]*N
expect_value[0] = cal_expect(p[0])

for i in range(1,K):
    expect_value[i] += expect_value[i-1] + cal_expect(p[i])

for i in range(K,N):
    expect_value[i] = expect_value[i-1] + cal_expect(p[i]) - cal_expect(p[i - K])

print(max(expect_value))
a = int(input())
b = int(input())
c = (a * b) / 2
if c == round(c):
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a = input().split()
b = int(a[1])
a = int(a[0])
if (a * b) % 2:
  print("Odd")
else:
  print("Even")
K, N = map(int, input().split())
 
A_list = list(map(int, input().split()))

distance = []
diff = 0

for i in range(0, N):
    
    if i == N-1:
        diff = K + A_list[0] - A_list[i]
        distance.append(diff)
        
    else:
        diff = A_list[i+1] - A_list[i]
        distance.append(diff)
        

print(sum(distance) - max(distance))

### FIXED CODE ###

S = input()

if (S[2] == S[3]) and (S[4] == S[5]):
    print("Yes")
    
else:
    print("No")
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

nn = int(input())
aa = list(map(int, input().split()))
gcd_list = list(range(nn))

for ii in list(range(nn)):
    aa2 = [x for x in aa]
    del aa2[ii]
    gcd_list[ii] = gcd(*aa2)
    
gcd = max(gcd_list)
print(gcd)

### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

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

L = [0]
R = [0]
for n in range(N-1):
    L.append(gcd(L[-1],A[n]))
    R.append(gcd(R[-1],A[N-n-1]))
    
GCDs = []
for n in range(N):
    GCDs.append(gcd(L[n], R[N-n-1]))
    
print(max(GCDs))
n = int(input())
d_array = [int(x) for x in input().split()]
d_dict = {}
for i in range(200000+1):
    d_dict[i] = 0
for d in d_array:
    d_dict[d] += 1
m = int(input())
t_array = sorted([int(x) for x in input().split()])

for t in t_array:
    if d_dict[t] > 0:
        d_dict[t] -= 1
    else:
        print("NO")
        break
else:
    print("YES")


### FIXED CODE ###

n = int(input())
d_array = [int(x) for x in input().split()]
d_dict = {}
for d in d_array:
    d_dict.setdefault(d, 0)
    d_dict[d] += 1
m = int(input())
t_array = sorted([int(x) for x in input().split()])

try:
    for t in t_array:
        if d_dict[t] > 0:
            d_dict[t] -= 1
        else:
            print("NO")
            break
    else:
        print("YES")
except KeyError:
    print("NO")
    exit()
def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    c = a % b
    return gcd(b, c)

n = int(input())
a = list(map(int, input().split()))

b = a[0]
for i in range(n - 1):
    b = math.gcd(a[i + 1], b)

print(b)

### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    c = a % b
    return gcd(b, c)

n = int(input())
a = list(map(int, input().split()))

b = a[0]
for i in range(n - 1):
    b = gcd(a[i + 1], b)

print(b)
import numpy as np
a=np.array([[0]*10]*12)
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[ 3*b-4+f, r-1 ] += v
for i in range(12):
    if i > 0 and i%3==0:
        print('#'*20)
    print(' ', end='')
    print(' '.join(a[i,]))

### FIXED CODE ###

towers = [
    [[0 for i in range(10)] for j in range(3)] for k in range(4)
]
floor = 3
 
n = int(input())
for i in range(n):
    b,f,r,v = list(map(int,input().split()))
    towers[b-1][f-1][r-1] += v
 
for b in towers:
    for f in b:
        for r in f:
            print(' ' + str(r), end='')
        print('')
    if floor:
        print('#'*20)
        floor -= 1
import math
n, m = [int(item) for item in input().split()]

ans = 1
for i in range(1, int(math.sqrt(m))+1):
  if m%i == 0 
    if m >= i*n:
      ans = max(ans, i)
    else:
      ans = max(ans, m%i)
    
print(ans)

### FIXED CODE ###

import math
n, m = [int(item) for item in input().split()]

ans = 0
for i in range(1, int(math.sqrt(m))+1):
  if m%i == 0:
    if m >= i*n:
      ans = max(ans, i)
    if i>= n:
      ans = max(ans, m//i)
    
print(ans)
def calc():
    d = a
    a = b
    b = d

    d = a
    a = c
    c = d

    print(a,b,c)

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


### FIXED CODE ###

def calc():
    x, y, z = c, a, b

    print(x, y, z)

a, b, c = map(int, input().split())
calc()
s=input()
t=input()
s_=sorted(s,reverse=True)
t_=sorted(t)
A.append(s_)
A.append(t_)
B=sorted(A)
if B[0]=s_t:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
t=input()
s_=sorted(s)
t_=sorted(t,reverse=True)
A=[]
A.append(s_)
A.append(t_)
B=sorted(A)
if B[0]==s_ and B[0]!=B[1]:
  print("Yes")
else:
  print("No")
n = int(input())
arr = [input() for _ in range(n)]
ans_dict = {}

for s in arr:
    tmp = sorted(s)
    if tmp in ans_dict:
        ans_dict[tmp] += 1
    else:
        ans_dict[tmp] = 1

ans = 0
for i in ans_dict.values():
    ans += i * ( i - 1) / 2
print( int(ans) )

### FIXED CODE ###

n = int(input())
arr = [input() for _ in range(n)]
dict = {}
alpha = "abcdefghijklmnopqrstuvwxyz"

for s in arr:
    count = [0]*26
    for i in range(10):
        for j in range(26):
            if s[i] == alpha[j]:
                count[j] += 1
                break
    count = tuple(count)
    if count not in dict:
        dict[count] = 1
    else:
        dict[count] += 1
ans = 0
for val in dict.values():
    ans += val * ( val - 1 ) / 2
print(int(ans))
A = int(raw_input())
A.split(' ')

{1:14}

if int(A) == int(B):
  print 'Draw'

elif int(A) ＞ int(B):
  print 'Alice'

elif int(B) ＞ int(A):
  print 'Bob'

### FIXED CODE ###

# -*- coading: utf-8 -#-

A = raw_input()
B = A.split()
C, D = int(B[0]), int(B[1])

if C == 1:
  if D == 1:
    print 'Draw'
  else:
    print 'Alice'
else:
  if D == 1:
    print 'Bob'
  else:
    if C > D:
      print 'Alice'
    elif C < D:
      print 'Bob'
    else:
      print 'Draw'
n,a,b,c,d=map(int,input().split());print('NYOE S'[any(i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*cfor i in range(n))::2])

### FIXED CODE ###

n,a,b,c,d=map(int,input().split())
f=0
for i in range(n):f|=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c
print('NYOE S'[f::2])
X,Y,Z= map(int, input().split())
print(max(X/(Z+Y)))

### FIXED CODE ###

X,Y,Z= map(int, input().split())
print((X-Z)//(Z+Y))
print(('Yes', 'No')[input() in 'AAA' or 'BBB'])

### FIXED CODE ###

S = input()
print('No' if S == 'AAA' or S == 'BBB' else 'Yes')
n=input()
#lst=list(n)
print(lst)
s=0
for i in lst:
    s+=int(i)
if s%9==0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n=input()
lst=list(n)
#print(lst)
s=0
for i in lst:
    s+=int(i)
if s%9==0:
    print('Yes')
else:
    print('No')
N,K=map(int,input().split())
List = list(map(int, input().split()))
INF = 10000000000
expList = [INF]*1000
def expectationF(num):
  if expList[num] == INF:
    exp = 0
    for i in range(1,num+1):
      exp += i/num
    expList[num] = exp
  return expList[num]

res = 0
mid = 0
midList=[]
for i in range(N):
  if i>=1:
    midList.append(expectationF(List[i])+midList[i-1])
  else:
    midList.append(expectationF(List[i]))
for j in range(N-K+1):
  if j == 0:
    mid = midList[j+K]
  else:
    mid = midList[j+K-1]- midList[j-1] 
  res = max(res,mid)
print(res)

### FIXED CODE ###

N,K=map(int,input().split())
List = list(map(int, input().split()))
INF = 10000000000
expList = [INF]*1001
def expectationF(num):
  if expList[num] == INF:
    exp = 0
    for i in range(1,num+1):
      exp += i/num
    expList[num] = exp
  return expList[num]

res = 0
mid = 0
midList=[]
for i in range(N):
  if i>=1:
    midList.append(expectationF(List[i])+midList[i-1])
  else:
    midList.append(expectationF(List[i]))
m=K-1
for j in range(N-m):
  if j == 0:
    mid = midList[j+m]
  else:
    mid = midList[j+m]- midList[j-1] 
  res = max(res,mid)
print(res)
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
  ans+=abs(a[i])
if a[0]>0:
  print(sum(a)-2*a[0])
else:
  print(ans)
plus=list()
minus=list()
for i in range(n):
  if a[i]>=0:
    plus.append(a[i])
  else:
    minus.append(a[i])
if len(minus)>0:
  while len(plus)>=2:
    p=plus.pop(0)
    m=minus.pop(0)
    minus.append(m-p)
    print(str(m)+' '+str(p))
if len(plus)>=2 and len(minus)==0:
  plus.sort()
  p1=plus.pop(0)
  p2=plus.pop(-1)
  minus.append(p1-p2)
  print(str(p1)+' '+str(p2))
if len(plus)==0:
  minus.sort()
  m1=minus.pop(-1)
  m2=minus.pop(-2)
  plus.append(m1-m2)
  print(str(m1)+' '+str(m2))
while len(minus)>0:
  p=plus.pop(0)
  m=minus.pop(0)
  plus.append(p-m)
  print(str(p)+' '+str(m))


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
xy=[]
for i in range(n-2,0,-1):
  y=a[i]
  if y>0:
    x=a[0]
    a[0]-=y
  else:
    x=a[n-1]
    a[n-1]-=y
  xy.append((x,y))
print(a[n-1]-a[0])
xy.append((a[n-1],a[0]))
print('\n'.join([' '.join(map(str,t)) for t in xy]))
n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
a = [0 for in range(s[len(s)-1])]
for i in s:
    a[i] += 1

count = 0
for i in t:
    count += a[i] 
print count

### FIXED CODE ###

n = int(raw_input())
s = map(int, raw_input().split())
m = int(raw_input())
t = map(int, raw_input().split())

s = list(set(s))
s.sort()
l = len(s)-1

count = 0
for i in t:
    low = 0
    high = l
    while low <= high:
        mid = (low+high)/2
        if s[mid] == i:
            count += 1
            break
        if s[mid] < i:
            low = mid+1
        else:
            high = mid-1

print count
S = input()
T = input()
count = 0
for i in [0:len(S)]:
  if S[i] != T[i]:
    count += 1
print(count)


### FIXED CODE ###

S = input()
T = input()
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
print(count)
h,w = tuple(map(int,input().split()))

a = [[int(t)for t in input().split()]for _ in [0]*h]

steps = []
for i in range(h):
  for j in range(w-1):
    if a[i][j]%2==1:
      steps.append((i,j,i,j+1))
      a[i][j+1]+=1

for i in range(h-1):
  if a[i][w-1]%2==1:
    steps.append((i,j,i+1,j))
    
print(len(steps))
for s in steps:
  print(*s)
      
      



### FIXED CODE ###

h,w = tuple(map(int,input().split()))

a = [[int(t)for t in input().split()]for _ in [0]*h]

steps = []
for i in range(h):
  if i%2==0:
    for j in range(w-1):
      if a[i][j]%2==1:
        steps.append((i+1,j+1,i+1,j+2))
        a[i][j+1]+=1
    if i!=h-1 and a[i][-1]%2==1:
      steps.append((i+1,w,i+2,w))
      a[i+1][-1] +=1
  else:
    for j in range(1,w)[::-1]:
      if a[i][j]%2==1:
        steps.append((i+1,j+1,i+1,j))
        a[i][j-1]+=1
    if i!=h-1 and a[i][0]%2==1:
      steps.append((i+1,1,i+2,1))
      a[i+1][0] +=1

    
print(len(steps))
for s in steps:
  print(*s)
def ct(pp, ls, xx, tct):
  tct[pp-1] += xx
  nodel = [i for i, x in enumerate(ls) if x == pp]:
  if bool(nodel):
    for j in nodel:
      ct(j, ls, xx, tct)
  return
 
N, Q = map(int, input().split())
nodeR = [0 for nn in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  nodeR[b-1] = a
tree_ct = [0 for nn in range(N)]
for j in range(Q):
  p, x = map(int, input().split())
  ct(p, nodeR, x, tree_ct)
print(' '.join(map(str, tree_ct)))

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
 
n,q = na()
g = [[] for i in range(n)]
c = [0]*n
 
for i in range(n-1):
    a,b = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
for i in range(q):
    p,x = na()
    c[p-1] += x
 
def f(b,a,r):
    r += c[a]
    c[a] = r
    for i in g[a]:
        if i != b:
            f(a,i,r)
 
f(-1,0,0)
print(' '.join([str(s) for s in c]))
N, K = list(map(int, input().split()))

#お菓子を持っていない : 1
#お菓子を持っている   : 0
#持っていない人を最終的に導くから
S = [1] * N 

for i in range(K):
    d = int(input())
    t = map(int, input().split())
    for i in range(t):
        #i-1なのは添字と要素tが1ぶんずれているから
        S[i-1] = 1
print(sum(S))

### FIXED CODE ###

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

#お菓子を持っていない : 1
#お菓子を持っている   : 0
#持っていない人を最終的に導くから
S = [1] * N 

for i in range(K):
    d = int(input())
    t = map(int, input().split())
    for i in t:
        #i-1なのは添字と要素tが1ぶんずれているから
        S[i-1] = 0
print(sum(S))