Harryxun/stf_run huggingface dataset:
import sys
 
stdin=sys.stdin
 
input = sys.stdin.readline


n,q=input()
AB=[[int(x) for x in input()] for _ in range(n-1)]
PX=[[int(x) for x in input()] for _ in range(q)]

graph=[[] for _ in range(n+1)]
values=[0]*(n+1)

for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

for p,x in PX:
    values[p]+=x

#print(graph)

def dfs(x,parent,add):
    values[x]+=add
    for i in graph[x]:
        if i==parent:
            continue
        dfs(i,x,values[x])

dfs(1,0,0)

print(' '.join(map(str,values[1:])))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

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

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
n=input()
word=input()
key=word[-1]
for i in range(1,n):
    word=input()
    if key==word[0]:
        key=word[-1]
    else:
        print("No")
print("Yes")


### FIXED CODE ###

n=int(input())
list=[]
word=input()
list.append(word)
key=word[-1]
flag=True
for i in range(1,n):
    word=input()
    if key==word[0] and (word not in list):
        list.append(word)
        key=word[-1]
    else:
        print("No")
        flag=False
        break
if flag:
    print("Yes")
N, K = map(int, input().rstrip().split(' '))
h = list(map(int, input().rstrip().split(' ')))
def frog_jump(n, height=h):
  if len(height[:n]) == 1:
    return 0
  now_height = height[n-1]
  start = n-1-K
  if start < 0:
    start = 0
  min_lst = [frog_jump(i) + abs(now_height-j) for i, j in enumerate(height[start:n-1], start+1)]
  # print(min_lst)
  min_cost = min(min_lst)
  return min_cost

print(frog_jump(N))

### FIXED CODE ###

N, K = map(int, input().rstrip().split(' '))
frog_lst = list(map(int, input().rstrip().split(' ')))
frog_jump_lst = []

def frog_jump(frog_jump_lst=[], index=0):
  if not frog_jump_lst:
    frog_jump_lst.append(0)
  else:
    now_pos = frog_lst[index]
    k = min(K, len(frog_jump_lst))
    pattern = [abs(now_pos - frog_lst[index-i]) + frog_jump_lst[-i] for i in range(1,k+1)]
    frog_jump_lst.append(min(pattern))

for j in range(N):
  frog_jump(frog_jump_lst, j)
print(frog_jump_lst[-1])
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    x.append(x_n)
    y.append(y_n)
    h.append(h_n)
for C_x in range(101):
    for C_y in range(101):
        if all(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y)==h[i+1]+abs(x[i+1]-C_x)+abs(y[i+1]-C_y) for i in range(N-1)):
            if h[1]+abs(x[1]-C_x)+abs(y[1]-C_y) >1 or h[1]+abs(x[1]-C_x)+abs(y[1]-C_y)==1:
                H=h[1]+abs(x[1]-C_x)+abs(y[1]-C_y)
                print(C_x,C_y,H)


### FIXED CODE ###

N=int(input())
if N==1:
    print("Hello World")
if N==2:
    A=int(input())
    B=int(input())
    print(A+B)
import math
n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

ans = t[0]
for i in range(1,n):
    ans = ans * t[i] // math.gcd(ans, t[i])
print(ans)

### FIXED CODE ###

import fractions
n = int(input())
t = []
for i in range(n):
    t.append(int(input()))

ans = t[0]
for i in range(1,n):
    ans = ans * t[i] // fractions.gcd(ans, t[i])
print(ans)
from itertools import accumulate

n, m = [int(x) for x in input().split()]
a = [0 for i in range(m + 2)]
for i in range(n):
	l, r = [int(x) for x in input().split()]
    a[l] += 1
    a[r + 1] -= 1
a = list(accumulate(a))
print(a.count(m))

### FIXED CODE ###

from itertools import accumulate

n, m = [int(x) for x in input().split()]
a = [0 for i in range(n + 2)]
for i in range(m):
    l, r = [int(x) for x in input().split()]
    a[l] += 1
    a[r + 1] -= 1
a = list(accumulate(a))
print(a.count(m))
s=input()
count1=0
count2=0

char1=s[0]
count1+=1
if s[1]==char1:
    count1+=1
else :
    char2=s[1]
    count2+=1

if s[2]==char1:
    count1+=1
elif s[2]==char2:
    char2=s[2]
    count2+=1
else:
    print('No')
    exit()

if s[3]==char1:
    count1+=1
elif s[3]==char2:
    char2=s[3]
    count2+=1
else:
    print('No')
    exit

if count1==2 and count2==2:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s=input()
count1=0
count2=0

char1=s[0]
char2='1'
count1+=1
if s[1]==char1:
    count1+=1
else :
    char2=s[1]
    count2+=1

if s[2]==char1:
    count1+=1
elif '1'==char2:
    char2=s[2]
    count2+=1
elif s[2]==char2:
    count2+=1

if s[3]==char1:
    count1+=1
elif '1'==char2:
    char2=s[3]
    count2+=1
elif s[3]==char2:
    count2+=1

if count1==2 and count2==2:
    print('Yes')
else:
    print('No')
a = input()
print(a+a*a+a*a*a)

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)
#最小全域木問題、プリム法
from heapq import *
def solve():
    N = int(input())
    A = [list(map(int, input().split()))+[i] for i in range(N)]
    edge = [[] for _ in range(N)]
    A.sort()
    for i in range(N-1):
        w = A[i+1][0]-A[i][0]
        edge[A[i][2]].append((w,A[i+1][2]))
        edge[A[i+1][2]].append((w,A[i][2]))
    A.sort(key=lambda x:x[1])
    for i in range(N-1):
        w = A[i+1][1]-A[i][1]
        edge[A[i][2]].append((w,A[i+1][2]))
        edge[A[i+1][2]].append((w,A[i][2]))
    bridges = []
    heapify(bridges)
    used = [False]*N
    used[0] = True
    ans = 0
    for w,v in edge[0]:
        heappush(bridges,(w,v))
    while len(bridges)>0:
        w,v = heappop(bridges)
        if used[v]==False:
            ans += w
            used[v] = True
            for w,u in edge[v]:
                if used[u]==False:
                    heappush(bridges,(w,u))
    return ans
print(solve())

### FIXED CODE ###

def check():
  X, A, B = map(int, input().split())
  if A>=B:
    return 'delicious'
  if B-A>X:
    return 'dangerous'
  return 'safe'
print(check())
def main():
    n, k = Input()
    data = sorted(int(input()) for _ in range(n))
    print(min([data[i+k-1] - data[i] for i in range(n-k+1)]))
main()

### FIXED CODE ###

def main():
    n, k = map(int, input().split(" "))
    data = sorted(int(input()) for _ in range(n))
    print(min([data[i+k-1] - data[i] for i in range(n-k+1)]))
main()
n = int(input())
s = {}
for i in range(n):
    d = input()
    if d in s:
        s[d] += 1
    else:
        s.update({d:1}) 

m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
    else:
        s.update({t:-1})

print("0" if max(d.values()) < 0 else max(d.values()))


### FIXED CODE ###

a,b,c = map(int,input().split())
print(["Yes","No"][a+b<c])
import math
N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] >= B * T:
            num += math.ceil((H[i] - B * T) / (A - B))
    return T > num


left, right = 1, max(H) // B + 1
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(mid)


### FIXED CODE ###

N, A, B = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)


def enough(T):
    num = 0
    for i in range(N):
        if H[i] - B * T > 0:
            num += (H[i] - B * T) // (A - B)
            num += int((H[i] - B * T) % (A - B) != 0)
    return T >= num


left, right = 0, 10 ** 9 + 1
mid = (left + right) // 2
while right - left > 1:
    mid = (left + right) // 2
    if enough(mid):
        right = mid
    else:
        left = mid

print(right)
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>=576490000000000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d ' % a[n-i])

### FIXED CODE ###

import sys
n = input()
a = map(int, raw_input().split())
for i in range(n):
  sys.stdout.write('%d' % a[n-i-1])
  if i != n-1:
    sys.stdout.write(' ')
sys.stdout.write('\n')
a = input()
print(chr(ord(a)+1)

### FIXED CODE ###

a = input()
print(chr(ord(a)+1))
import math

n,d = map(int,input().split())

k = n/(d*2+1)
print(math.ceil(k))

### FIXED CODE ###

r = int(input())
print(3*r**2)
x = input()
print(x**3)

### FIXED CODE ###

a = int(input())
print(a**3)
INF = int(1e9) + 7

n = int(input())
a = list(map(int, input().split()))
col = [0,0,0]
ans = 1
for i in range(n):
        col[i] +=1
        continue
    c = set(col)
    m = 0
    for j in range(3):
        if c==col[j]:
            m +=1
    ans *= m
    
    for j in range(3):
        if i==col[j]:
            col[j] +=1
            break
        else:
            continue
    ans = ans%INF

print(ans)

### FIXED CODE ###

INF = int(1e9) + 7

n = int(input())
a = list(map(int, input().split()))
col = [0, 0, 0]
ans = 1
for i in range(n):
    m = 0
    for j in range(3):
        if a[i] ==col[j]:
            m = col.count(a[i])
    ans *= m
    
    for j in range(3):
        if a[i]==col[j]:
            col[j] +=1
            break
        else:
            continue
    ans = ans%INF

print(ans)
n = int(raw_input())
h = {}
un = set()
for i,b in enumerate(map(int,raw_input().split())):

	for a in un:
		if a != b:
			h[(a,b)] = (h[(b,a)] if (b,a) in h else 1) + 1
	un.add(b)

print n - max(h.values())

### FIXED CODE ###

import collections
n = int(raw_input())
ais = map(int, raw_input().split(' '))
cco = collections.Counter([ais[i] for i in range(len(ais)) if i % 2])
cce = collections.Counter([ais[i] for i in range(len(ais)) if i % 2 == 0])
cce = [(cce[k],k) for k in cce]
cce.sort(key = lambda x:-x[0])

t = n/2
if cce:
	m = t + t- cce[0][0]
else:
	m = 2*t
for colori in cco:
	for v,colorj in cce:
		if colorj != colori:
			m = min(m,t - cco[colori] + t - v)
			break

print m
a,b=int(raw_input())
if a<b: print 'a < b'
elif a>b: print'a > b'
else: print 'a == b' 

### FIXED CODE ###

a,b=map(int,raw_input().split())
if a<b: print 'a < b'
elif a>b: print'a > b'
else: print 'a == b'
from sys import stdin, stdout  

X,Y,A,B,C = [int(c) for c in input().split()]

p= [int(c) for c in input().split()]
q= [int(c) for c in input().split()]
r= [int(c) for c in input().split()]

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:X]
q=q[:Y]
    
p.sort()
q.sort()
res=sum(p)+sum(q)

i=j=0

for k,val in enumerate(r):
    if(val<=p[i] and val <= q[j]):
        break
    if(val>p[i] and val<q[j]):
        res=res+val-p[i]
        i=i+1
    if(val<p[i] and val>q[j]):
        res=res+val-q[j]
        j=j+1
    if(val>p[i] and val>q[j]):
        if(p[i]>q[j]):
            res=res+val-q[j]
            j=j+1
        else:
            res=res+val-p[i]
            i=i+1
        
print(res)

### FIXED CODE ###

from sys import stdin, stdout  

X,Y,A,B,C = [int(c) for c in input().split()]

p= [int(c) for c in input().split()]
q= [int(c) for c in input().split()]
r= [int(c) for c in input().split()]

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:X]
q=q[:Y]
    
p.sort()
q.sort()
res=sum(p)+sum(q)

i=j=0

for k,val in enumerate(r):
    if(i<len(p) and j<len(q)):
        if(val<=p[i] and val <= q[j]):
            break
        elif(val>p[i] and val<q[j]):
            res=res+val-p[i]
            i=i+1
        elif(val<p[i] and val>q[j]):
            res=res+val-q[j]
            j=j+1
        elif(val>p[i] and val>q[j]):
            if(p[i]>q[j]):
                res=res+val-q[j]
                j=j+1
            else:
                res=res+val-p[i]
                i=i+1
    elif(i<len(p) and j==len(q)):
        if(val<=p[i]):
            break
        elif(val>p[i]):
            res=res+val-p[i]
            i=i+1
    elif(i==len(p) and j<len(q)):
        if(val<=q[j]):
            break
        elif(val>q[j]):
            res=res+val-q[j]
            j=j+1
    elif(i==len(p) and j==len(q)):
        break
        
print(res)
N = int(input())
li_p = list(map(int, input().split()))
li = set(li_p)
li_a = []
li_b = []
for i in range(N):
  if li_p[i] != li[i]:
    li_a.append(li_p[i])
    li_b.append(li[i])
    if len(li_a) == 2:
      if li_a[0] == li_b[1]:
        print("YES")
      else:
        print("NO")
    elif len(li_a) > 2:
      print("NO")
    elif len(li_a) == 0:
      print("YES")
    
  
  

### FIXED CODE ###

N = int(input())
li_p = list(map(int, input().split()))
li_a = sorted(li_p)
#print(li_a)
#print(li_p)
a = 0
for i in range(N):
  if li_p[i] != li_a[i]:
    a += 1
    
if a <= 2:
  print("YES")
else:
  print("NO")
s = input()
if (s[3] == s[4]) and (s[5] == s[6]):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = input()
if (s[2] == s[3]) and (s[4] == s[5]):
  print('Yes')
else:
  print('No')
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
    if A[i]<=0:
        B.append(-A[i])
    else:
        C.append(A[i])
b=min(B)
c=min(C)
d=min(b,c)
if len(B)%2==0:
       print(sum(B)+sum(C))
else:
       print(sum(B)+sum(C)-2*c)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
    if A[i]<=0:
        B.append(-A[i])
    else:
        C.append(A[i])
if len(B)%2==0:
       print(sum(B)+sum(C))
else:
        if C==[]:
            print(sum(B)+sum(C)-2*min(B))
        else:
            print(sum(B)+sum(C)-2*min(min(B),min(C)))
N = int(input())
print(3*r**2)

### FIXED CODE ###

r = int(input())
print(3*r**2)
N , L= map(int,input().split())
lst = []
Str = ''
for i in range(N):
    lst.append(input())
for k in range(N):
    for M in range(M-1):
        if lst[M] > lst[M+1]:
            lst[M],lst[M+1] = lst[M+1] , lst[M]
for j in range(N):
    Str += lst[j]
print(Str)


### FIXED CODE ###

N,L=map(int, input().split())
S=[]
for i in range(N):
    S.append(input())
S.sort()
result=''
for j in range(N):
    result+=S[j]     
print(result)
def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n):
        for a, b, c in ABC:
            if distance[a - 1] is not None and distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for a, b, c in ABC:
        if distance[b - 1] < distance[a - 1] + c:
            return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))


### FIXED CODE ###

def solve(n, m, ABC):
    distance = [None] * n
    distance[0] = 0

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None:
                continue
            if distance[b - 1] is None or distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c

    for _ in range(n - 1):
        for a, b, c in ABC:
            if distance[a - 1] is None or distance[b - 1] is None:
                continue
            if distance[b - 1] < distance[a - 1] + c:
                distance[b - 1] = distance[a - 1] + c
                if b == n:
                    return 'inf'

    return distance[n - 1]

_n, _m = map(int, input().split())
_ABC = [list(map(int, input().split())) for _ in range(_m)]
print(solve(_n, _m, _ABC))
"""
問題文
    N段の階段があります。高橋君は現在、上り口(0段目)にいます。 高橋君は一歩で1段か2段上ることができます。
    ただし、a1,a2,a3,....aM段目の床は壊れており、その段に足を踏み入れることは危険です。
    壊れている床を踏まないようにしながら、最上段(N段目)にたどりつくまでの移動方法は何通りあるでしょうか？ 
    総数を1,000,000,007で割った余りを求めてください。

制約
    1≦N≦10^5
    0≦M≦N−1
    1≦a1<a2< ... <aM≦N−1
"""
#入力の受け取り
N, M = map(int, input().split())
hoal = [int(input()) for i in range(M)]

#listの初期化
dp = list()
dp = [0]*N
dp[0] = 1
dp[1] = 2


if 1 in hoal:
    dp[0] = 0
    dp[1] = 1
dp_check = list()
dp_check = [0]*N

for i in range(M):
    dp_check[hoal[i]-1]=1
    if dp_check[hoal[i]-1]==1 and dp_check[hoal[i]-2]==1:
        print("0")
        exit()

#実際に求める
#dp[i]<-i段までの移動方法の和
for i in range(N):
    if i>1 and dp_check[i]==0:
        dp[i]=dp[i-1]+dp[i-2]

    dp[i]=dp[i]%1000000007

print(dp[N-1])
    

### FIXED CODE ###

"""
問題文
    N段の階段があります。高橋君は現在、上り口(0段目)にいます。 高橋君は一歩で1段か2段上ることができます。
    ただし、a1,a2,a3,....aM段目の床は壊れており、その段に足を踏み入れることは危険です。
    壊れている床を踏まないようにしながら、最上段(N段目)にたどりつくまでの移動方法は何通りあるでしょうか？ 
    総数を1,000,000,007で割った余りを求めてください。

制約
    1≦N≦10^5
    0≦M≦N−1
    1≦a1<a2< ... <aM≦N−1
"""
#入力の受け取り
N, M = map(int, input().split())
hoal = [int(input()) for i in range(M)]

#listの初期化
dp = list()
dp = [0]*N

    
dp_check = list()
dp_check = [0]*N

for i in range(M):
    dp_check[hoal[i]-1]=1
    if dp_check[hoal[i]-1]==1 and dp_check[hoal[i]-2]==1:
        print("0")
        exit()

if N==1:
    if M==1:
        dp[0]=0
    else:
        dp[0]=1
    print(dp[N-1])
else:
    if dp_check[0]==1:
        dp[0]=0
        dp[1]=1
    elif dp_check[1]==1:
        dp[0]=1
        dp[1]=0
    else:
        dp[0] = 1
        dp[1] = 2
    #実際に求める
    #dp[i]<-i段までの移動方法の和
    for i in range(N):
        if i>1 and dp_check[i]==0:
            dp[i]=dp[i-1]+dp[i-2]

        dp[i]=dp[i]%1000000007

    print(dp[N-1])
N,K=map(int,input().split())

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

xm=[]
xp=[]
x0=[]
ans=10**5+1

for i in range(N):
    xi=x[i]
    if xi<0:
        xm.append(xi)
    elif xi==0:
        x0.append(xi)
    else:
        xp.append(xi)

xm.sort(reverse=True)

if x0==[]:
    ajst=0
else:
    ajst=1

K=K-ajst

for i in range(min(len(xp),K)):
    if i<K-1:
        if len(xm)>=K-(i+1):
            ans=min(ans,2*xp[i]-xm[K-ajst-(i+1)-1])
    
    else:#i==K-1
        ans=min(ans,xp[i])

for i in range(min(len(xm),K)):
    if i<K-1:
        if len(xp)-1>=K-(i+1):
            ans=min(ans,-2*xm[i]+xp[K-ajst-(i+1)-1])
    
    else:#i==K-1
        ans=min(ans,-xm[i])

if K==１ and x0!=[]:
    ans=0

print(ans)

### FIXED CODE ###

N,K=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
m=10**9
for i in range(N-K+1):
    m=min(m,X[K-1+i]-X[i]+min(abs(X[K-1+i]),abs(X[i])))

print(m)
import sys
from collections import deque


def solve(n, m, links):
    if m % 2 == 1:
        print(-1)
        return

    going = [set() for _ in range(n)]
    tree = [{} for _ in range(n)]
    parents = [-1] * n
    q = deque([0])
    while q:
        v = q.popleft()
        for u in links[v]:
            if v in going[u]:
                continue
            going[v].add(u)
            if parents[u] == -1:
                tree[v][u] = 0
                parents[u] = v
            q.append(u)

    parities = [len(l) % 2 for l in going]

    # print(going)
    # print(tree)
    # print(parents)
    # print(parities)

    def dfs(v):
        b = parities[v]
        for u in tree[v]:
            c = dfs(u)
            b ^= c
        if b:
            p = parents[v]
            if p != -1:
                tree[p][v] ^= 1
        return b

    dfs(0)

    ans = []
    for v in range(n):
        for u in going[v]:
            if u not in tree[v]:
                ans.append('{} {}'.format(v + 1, u + 1))
            elif tree[v][u] == 0:
                ans.append('{} {}'.format(v + 1, u + 1))
            else:
                ans.append('{} {}'.format(u + 1, v + 1))
    print('\n'.join(ans))


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

links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)

solve(n, m, links)


### FIXED CODE ###

import sys
from collections import deque

sys.setrecursionlimit(10 ** 5)


def solve(n, m, links):
    if m % 2 == 1:
        print(-1)
        return

    tree = [set() for _ in range(n)]
    parents = [-1] * n
    q = deque([0])
    while q:
        v = q.popleft()
        for u in links[v]:
            if parents[u] == -1:
                tree[v].add(u)
                parents[u] = v
                q.append(u)
            links[u].remove(v)

    parities = [len(l) % 2 for l in links]

    # print(links)
    # print(tree)
    # print(parents)
    # print(parities)

    def dfs(v):
        b = parities[v]
        for u in tree[v]:
            c = dfs(u)
            b ^= c
        if b:
            p = parents[v]
            links[p].remove(v)
            links[v].add(p)
        return b

    dfs(0)

    ans = ['{} {}'.format(v + 1, u + 1) for v in range(n) for u in links[v]]
    print('\n'.join(ans))


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

links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)

solve(n, m, links)
import math

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        di[tmp] += 1

for v in di.values():
    if v > 1:
        answer += int(math.factorial(v) / 2)
print(answer)


### FIXED CODE ###

import math

n = int(input())
di = dict()
answer = 0

for i in range(n):
    tmp = str(sorted(input()))
    if di.get(tmp, 0) == 0:
        di[tmp] = 1
    else:
        answer += di[tmp]
        di[tmp] += 1

print(answer)
# coding: utf-8
 
def count_char_max(text):
 
  a = "abcdefghijklmnopqrstuvwxyz"
  l = [0] * 26
 
  for i in text:
 
    ascNum = ord(i.lower()) - 97
 
    if ascNum < 0 or 25 < ascNum:
      continue
 
    l[ascNum] += 1
 
  return max(l)
 
s = raw_input()

for i in len(s):

  if (s[i] == s[i + 1]):
    print "%d %d" % (i + 1, i + 2)
    quit()

  elif (count_char_max(s[i:i+3]) == 2):
    print "%d %d" % (i + 1, i + 3)
    quit()

print "-1 -1"

### FIXED CODE ###

# coding: utf-8
 
def count_char_max(text):
 
  a = "abcdefghijklmnopqrstuvwxyz"
  l = [0] * 26
 
  for i in text:
 
    ascNum = ord(i.lower()) - 97
 
    if ascNum < 0 or 25 < ascNum:
      continue
 
    l[ascNum] += 1
 
  return max(l)
 
s = raw_input()

for i in range(len(s) - 1):

  if (s[i] == s[i + 1]):
    print "%d %d" % (i + 1, i + 2)
    quit()

for i in range(len(s) - 2):

  if (count_char_max(s[i:i+3]) == 2):
    print "%d %d" % (i + 1, i + 3)
    quit()

print "-1 -1"
N, X = map(int, input().split())
L = list(map(int, input().split())
di = 0
for i in range(N):
  if di < X:
    di += L[i]
  else:
    print(i)
    break

### FIXED CODE ###

N,X=map(int,input().split())
L=list(map(int,input().split()))
count=1
tmp=0
for i in range(N):
  tmp+=L[i]
  if tmp<=X:
    count+=1
print(count)
m,d=map(int,input().split())
a,b=map(int,input().split())
if a=m+1:
    print("1")
else:
    print("0")

### FIXED CODE ###

m,d=map(int,input().split())
a,b=map(int,input().split())
if a==m+1:
    print("1")
else:
    print("0")
import sys
sys.setrecursionlimit(20000*20000)

S = str(input())
ans = set()
check = set()

def dfs(i, j):
    if (i, j) in check:
        return
    else:
        check.add((i, j))
    if int(S[i:j+1])%2019 == 0:
        ans.add((i, j))
    if j == len(S)-1:
        return

    dfs(i+1, j+1)
    dfs(i, j+1)

if len(S) < 4:
    print(0)

else:
    dfs(0, 3)
    print(len(ans))

### FIXED CODE ###

s, w = map(int, input().split())

if s <= w:
    print('unsafe')
else:
    print('safe')