Harryxun/stf_run huggingface dataset:
import sys

counts = list(map(int,input().split()))
colors = list(map(int,input().split()))
hots = list(map(int,input().split()))
colorsCount = counts[0]
hotsCount = counts[1]
ticketCount = counts[2]

minPrice = sys.maxsize
# first. get disscount consider price
for i in range(ticketCount):
  values = input().split()
  x = int(values[0])
  y = int(values[1])
  dissPrice = int(values[2])
  colorPrice = colors[x-1]
  hotsPrice = hots[y-1]
  validPrice =  colorPrice + hotsPrice - dissPrice
  if minPrice > validPrice:
    minPrice = validPrice

max_color = max(colors)
max_color_idx = colors.index(max_color)
max_hots = max(hots)
max_hots_idx = hots.index(max_hots)
validPrice = max_color + max_hots
if minPrice > validPrice:
  minPrice = validPrice
print(str(minPrice))

### FIXED CODE ###

import re

pattern = '(hi)+'
compiled = re.compile(pattern)
input_value = input()
result = compiled.match(input_value)
if result == None:
  print('No')
elif result.group() == input_value:
  print('Yes')
else:
  print('No')
import copy
N , C = map(int, input().split())
ds =[list(map(int, input().split())) for i in range(C)]
cs =[list(map(int, input().split())) for i in range(N)]
c0 = []
c1 = []
c2 = []
for i in range(N):
    for j in range(N):
        if (i+j) % 3 == 0:
            c0.append(cs[i][j])
        elif (i+j) % 3 == 1:
            c1.append(cs[i][j])
        else:
            c2.append(cs[i][j])
d = 10**9
l0 = len(c0)
l1 = len(c1)
l2 = len(c2)
for i in range(C):
     d0 = 0
    for l in range(l0):
        if (c0[l]-1) != i:
            d0 += ds[c0[l]-1][i]
    for j in range(C):
        if i == j:
            continue
        d1 = copy,copy(d0)
        for h in range(l1):
            if (c1[h]-1) != j:
                d1 += ds[c1[h]-1][j]
        for k in range(C):
            if i == k or j == k:
                continue
            d2 = copy.copy(d1)
            for l in range(l2):
                if (c2[l]-1) != k:
                    d2 += ds[c2[l]-1][k]
            if d > d2:
                d = d2
print(d)

### FIXED CODE ###

import collections
N , C = map(int, input().split())
ds =[list(map(int, input().split())) for i in range(C)]
cs =[list(map(int, input().split())) for i in range(N)]
c0 = collections.defaultdict(int)
c1 = collections.defaultdict(int)
c2 = collections.defaultdict(int)
for i in range(N):
    for j in range(N):
        if (i+j) % 3 == 0:
            c0[cs[i][j]] += 1
        elif (i+j) % 3 == 1:
            c1[cs[i][j]] += 1
        else:
            c2[cs[i][j]] += 1
            
d = 10**9
for i in range(C):
    for j in range(C):
        if i == j:
            continue
        for k in range(C):
            if i == k or j == k:
                continue
            d0 = 0
            for l in c0:
                d0 += c0[l] * ds[l-1][i]
            for l in c1:
                d0 += c1[l] * ds[l-1][j]
            for l in c2:
                d0 += c2[l] * ds[l-1][k]
            if d > d0:
                d = d0
            
print(d)
class UnionFindTree:
    def __init__(self, N):
        self.root = [i for i in range(N + 1)]
        self.friendcount = [1 for i in range(N + 1)]

    def getroot(self, x):
        node = self.root[x]
        if node == x:
            return x
        self.root[x] = self.getroot(node)
        return self.root[x]

    def unite(self, x, y):
        xroot = self.getroot(x)
        yroot = self.getroot(y)
        if xroot == yroot:
            return
        self.root[xroot] = yroot
        self.friendcount[yroot] += self.friendcount[xroot]

    def getfriendcount(self, x):
        xroot = self.getroot(x)
        return self.friendcount[xroot]

    def same(self, x, y):
        if self.getroot(x) == self.getroot(y):
            return True
        return False


N, M, K = map(int, input().split())
A = [0] * M
B = [0] * M
C = [0] * K
D = [0] * K

for i in range(M):
    A[i], B[i] = map(int, input().split())
for i in range(K):
    C[i], D[i] = map(int, input().split())

tree = UnionFindTree(N)
for i in range(M):
    tree.unite(A[i], B[i])

friendscount = [0] * (N + 1)
blockcount = [0] * (N + 1)
for i in range(M):
    friendscount[A[i]] += 1
    friendscount[B[i]] += 1
for i in range(K):
    if tree.same(C[i], D[i]):
        blockcount[C[i]] += 1
        blockcount[D[i]] += 1

# print(1, 4, tree.same(1, 4))
# print(1, tree.getfriendcount(1))
# print(4, tree.getfriendcount(4))

result = [str(tree.getfriendcount(i) - 1 - friendscount[i] - blockcount[i]) for i in range(1, N + 1)]
print(" ".join(result))


### FIXED CODE ###

class UnionFindTree:
    def __init__(self, N):
        self.root = [i for i in range(N)]
        self.friendcount = [1] * N

    def getroot(self, x):
        node = self.root[x]
        if node == x:
            return x
        self.root[x] = self.getroot(node)
        return self.root[x]

    def unite(self, x, y):
        xroot = self.getroot(x)
        yroot = self.getroot(y)
        if xroot == yroot:
            return
        if xroot > yroot:
            self.root[xroot] = yroot
            self.friendcount[yroot] += self.friendcount[xroot]
        else:
            self.root[yroot] = xroot
            self.friendcount[xroot] += self.friendcount[yroot]

    def getfriendcount(self, x):
        xroot = self.getroot(x)
        return self.friendcount[xroot]

    def same(self, x, y):
        if self.getroot(x) == self.getroot(y):
            return True
        return False


N, M, K = map(int, input().split())
A = [0] * M
B = [0] * M
C = [0] * K
D = [0] * K

for i in range(M):
    A[i], B[i] = map(int, input().split())
for i in range(K):
    C[i], D[i] = map(int, input().split())

tree = UnionFindTree(N + 1)
for i in range(M):
    tree.unite(A[i], B[i])

friendscount = [0] * (N + 1)
blockcount = [0] * (N + 1)
for i in range(M):
    friendscount[A[i]] += 1
    friendscount[B[i]] += 1
for i in range(K):
    if tree.same(C[i], D[i]):
        blockcount[C[i]] += 1
        blockcount[D[i]] += 1

result = [str(tree.getfriendcount(i) - 1 - friendscount[i] - blockcount[i]) for i in range(1, N + 1)]
print(" ".join(result))
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
x,y=map(int,input())
if a.count(x)==a.count(y) and b.count(x)==b.count(y) and c.count(x)==c.count(y):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
x,y=map(int,input().split())
if a.count(x)==a.count(y) and b.count(x)==b.count(y) and c.count(x)==c.count(y):
  print('Yes')
else:
  print('No')
P, n = map(int, input().split())
struct = [list(map(int, input().split())) for x in range(P-1)]
act = [list(map(int, input().split())) for y in range(n)]

A = []


def add_val(action):
    idx = action[0]
    val = action[1]

    A[idx][0] += val

    if A[idx][1]:
        for r in A[idx][1]:
            add_val([r, val])


for a in range(P + 1):
    A.append(list([0, []]))

for z in struct:
    p = z[0]
    p_ = z[1]
    A[p][1].append(p_)

for _ in act:
    add_val(_)


As = []
for _ in range(1, len(A)):
    As.append(A[_][0])

print(*As, sep=' ')


### FIXED CODE ###

from collections import deque

N, Q = map(int, input().split())
edge = [[] for i in range(N)]
ops = []
ans = [0] * N

for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
for _ in range(Q):
    ops.append(tuple(map(int, input().split())))

for op in ops:
    node = op[0] - 1
    pnt = op[1]
    ans[node] += pnt

stack = deque()
stack.append((0, -1))

while stack:
    st = stack.pop()
    node, parent = st[0], st[1]
    children = edge[node]
    for child in children:
        if child == parent:
            continue
        ans[child] += ans[node]
        stack.append((child, node))

print(*ans)
s = input()
for i in range(ord('a'), ord('z')+1):
  if i in s:
    print(i)
    break
else:
  print('None')

### FIXED CODE ###

s = input()
for i in range(ord('a'), ord('z')+1):
  if chr(i) not in s:
    print(chr(i))
    break
else:
  print('None')
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=-1
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r)//2
	for x in a:
		if x>1:
			cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=max(a)+1
while r-l>1:
	cnt=0
	mid=(l+r+1)//2
	if mid==0:
		print(1)
		exit()
	for x in a:
		if x>1:
			cnt+=(x-1)//mid
	if cnt<=k:
		r=mid
	else:
		l=mid
print(r)
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = map(int, input().split())
for i in range(1, k+1):
    red = cmb(k-1, i-1)
    blue = cmb(n-k+1, i)
    print(red*blue%(10**9+7))


### FIXED CODE ###

N, K = map(int, input().split())
MOD = 10 ** 9 + 7

MAX = 4000
fact = [0] * MAX
invfact = [0] * MAX
fact[0] = 1
for i in range(1, MAX):
    fact[i] = fact[i - 1] * i % MOD
invfact[MAX - 1] = pow(fact[MAX - 1], MOD-2, MOD)
for i in range(MAX - 2, -1, -1):
    invfact[i] = invfact[i+1] * (i+1) % MOD

def nCk(n, k):
    if k < 0 or n < k: return 0
    return (fact[n] * invfact[k] % MOD) * invfact[n-k] % MOD

ans = 0
red = N - K
for i in range(1,1+K):
    ans = nCk(red+1, i) * nCk(K-1, i-1)
    ans %= MOD
    print(ans)
#coding:utf-8
n = int(input())
a = input()
b = input()
c = input()
ans = 0

for i in range(n):
  ans += len(set(a[i], b[i], c[i])) - 1 
  
print(ans)


### FIXED CODE ###

#coding:utf-8
n = int(input())
a = input()
b = input()
c = input()
ans = 0
 
for i in range(n):
  ans += len(set([a[i], b[i], c[i]])) - 1 
  
print(ans)
n,m = map(int,input().split())
a = [-1]
flag = True
for i in range(m):
  a.append(int(input()))
  if i>0 and a[i+1]==a[i]+1:
    flag = False
    break
if not flag:
  print(0)
a.append(n+1)

step = [a[i+1]-a[i]-1 for i in range(m+1)]

onestep = [1,1]
if max(step)>=3:
  for i in range(3,max(step)+1):
    onestep.append(onestep[-2]+onestep[-1])

ans = 1
for i in range(m+1):
  ans *= onestep[step[i]-1]
if flag:
  print(ans%1000000007)

### FIXED CODE ###

n,m = map(int,input().split())
a = [-1]
flag = True
 
if m>0:
  for i in range(m):
    a.append(int(input()))
    if a[i+1]==a[i]+1:
      flag = False
      break
  if not flag:
    print(0)
  else:
    a.append(n+1)
    step = [a[i+1]-a[i]-1 for i in range(m+1)]
    onestep = [1,1]
    if max(step)>=3:
      for i in range(3,max(step)+1):
        onestep.append(onestep[-2]+onestep[-1])
  
    ans = 1
    for i in range(m+1):
      ans *= onestep[step[i]-1]
    print(ans%1000000007)
else:
  onestep=[1,1]
  if n==1:
    print(1)
  else:
    for i in range(2,n+1):
      onestep.append(onestep[-2]+onestep[-1])
    print(onestep[-1]%1000000007)
s = int(input())
n = 1
tmp = s
if s == 1 or s == 2:
    print(4)
else:
    for i in range(1, 1000000):
        if tmp == 4:
            n = i
            break
        elif tmp % 2 == 0:
            tmp = tmp//2
        else:
            tmp = 3*tmp + 1
    print(n+3)

### FIXED CODE ###

a, b, c = map(int, input().split())
area = int(1/2*a*b)
print(area)
a = []
for i in range(5):
    a.append(input())
W = list[0] 
H = list[1] 
x = list[2]
y = list[3]
r = list[4]

if x-r < 0:
    print("No")
elif x + r > W:
    print("No")
elif y-r < 0:
    print("No")
elif y+r > H:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

W,H,x,y,r = [int(i) for i in input().split(" ")]

print("No" if x < r or y < r or x + r > W or y + r > H else "Yes" )
N = int(input())
2 s = [input() for i in range(N)]
3 for v in ['AC', 'WA', 'TLE', 'RE']:
4 print('{0} x {1}'.format(v, s.count(v)))


### FIXED CODE ###

N = int(input())

a = [0]*N
for i in range(N):
    a[i]=input()

result=[0]*4
for i in range(len(a)):
    if a[i] == "AC":
        result[0]+=1

    if a[i] == "WA":
        result[1]+=1

    if a[i] == "TLE":
        result[2]+=1

    if a[i] == "RE":
        result[3]+=1

print("AC x ",result[0])
print("WA x ",result[1])
print("TLE x ",result[2])
print("RE x ",result[3])
a,b=map(int,input().split())
if max(a,b)>9:
  print(-1)
else:
  print(a＊b)


### FIXED CODE ###

a,b=map(int,input().split())
if max(a,b)>9:
  print('-1')
else:
  print(a*b)
S = input()

if S = 'ABC':
    print('ARC')
else:
    print('ABC')


### FIXED CODE ###

S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')
m = map(int, input().split())
print m[0]*m[1],2*(m[0]+m[1])

### FIXED CODE ###

m = map(int,raw_input().split())
print m[0]*m[1],2*(m[0]+m[1])
l1=list(map(str,input().split()))
l2=list(map(str,input().split()))

cnt=0
for i in range(len(l1)):
    if l[i]==l[-i-1]:
        cnt+=1

if cnt == 3:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s1=input()
s2=input()

cnt=0
for i in range(len(s1)):
    if s1[i]==s2[-i-1]:
        cnt+=1

if cnt == 3:
    print("YES")
else:
    print("NO")
# coding: utf-8

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#main
X = int(input())
F = make_divisors(X)
#intのみのlistは、直接.join()できない
S = [int(x) for x in F]

for i in range(len(S)):
    tmp = S[i]
    for A in range(S[i+1]):
        B = A - tmp
        if A**5 - B**5 == X:
            print(str(A) + ' ' + str(B))
            break
    else:
        continue
    break

### FIXED CODE ###

# coding: utf-8

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

#main
X = int(input())
F = make_divisors(X)
#intのみのlistは、直接.join()できない
S = [int(x) for x in F]

for i in range(len(S)):
    tmp = S[i]
    for A in range(-1000, 1001):
        B = A - tmp
        if A**5 - B**5 == X:
            print(str(A) + ' ' + str(B))
            break
    else:
        continue
    break
#! /usr/bin/python3
# こだわり者いろはちゃん / Iroha's Obsession

"""
    1≦N<10000
    1≦K<10
    0≦D1<D2<…<DK≦9
    {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
"""

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

test_mode = False


def check_num(x, d, n):
    """
    金額xの中に中の文字があるか確認する関数。
    x : 現在の金額（N, x+n を想定）
    d : 嫌いな数字のリスト（D を想定）
    n : 元の金額（N を想定）
    文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、
    含まれていたら元の金額 n を足して再試行する。
    """
    if test_mode:
        print('x =', x)
    for num in d:
        if test_mode:
            print('num =', num)
        str_x = str(x)
        str_num = str(num)
        if str_num in str_x:
            return check_num(x+n, d, n)
    return x


def main():
    """
    金額を算出して出力
    """
    amount = check_num(N, D, N)
    print(amount)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#! /usr/bin/python3
# こだわり者いろはちゃん / Iroha's Obsession
# 参考 : https://abc042.contest.atcoder.jp/submissions/3419872

"""
    1≦N<10000
    1≦K<10
    0≦D1<D2<…<DK≦9
    {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
"""

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

test_mode = False


def check_num(x, d):
    """
    金額xの中に中の文字があるか確認する関数。
    x : 現在の金額（N, x+1 を想定）
    d : 嫌いな数字のリスト（D を想定）
    文字列 x にリスト d 中の要素が含まれているか、d の要素 num を順に確認し、
    含まれていたら1円足して再試行する。
    """
    if test_mode:
        print('x =', x)
    while len(set(list(str(x))) & d) != 0:
        x += 1
    return x


def main():
    """
    金額を算出して出力
    """
    amount = check_num(N, D)
    print(amount)


if __name__ == '__main__':
    main()
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

threshhold = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
    if val > threshhold:
    ##print(val)
        c += 1

if M > c:
    print('No')
else:
    print('Yes')


### FIXED CODE ###

i = input()
l = i.split()
print(l[2] + ' ' + l[0] + ' ' + l[1])
n,q=map(int,input().split())
d = {}
ans = [0]*(n+1)
for i in range(n-1):
    sta,gol = map(int,input().split())
    if sta not in d:
        d[sta] = set() 
    d[sta].add(gol)

dv = {}
for i in range(q):
    sta,val = map(int,input().split())
    if sta not in dv:
        dv[sta] = val 
    else:
        dv[sta]+=val
    

#print(d)
#print(dv)  

def cal_(ans_,sta_,flow):
    val_ = flow
    if sta_ in dv:
        val_ +=dv[sta_]
    
    ans_[sta_]+=val_
    
    if sta_ in d:
        targetset = d[sta_]
        for t in targetset:
            ans_=cal_(ans_,t,val_)
    return ans_

ans = cal_(ans,1,0)

anss = ""
for i in range(n):
    anss = anss+str(ans[i+1])+" "
print(anss)

### FIXED CODE ###

n,q=map(int,input().split())
d = {}
ans = [0]*(n+1)
for i in range(n-1):
    sta,gol = map(int,input().split())
    d[gol] = sta

for i in range(q):
    sta,val = map(int,input().split())
    ans[sta]+=val
    

for i in range(n):
    gol = i+1
    if gol in d:
        ans[gol]+=ans[d[gol]]
    

for i in range(n):
    print(ans[i+1], " ",end="")
import sys
sys.setrecursionlimit(10**7)

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

ab = [[] for j in range(n)]
cd = [[] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
    
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
check = [-1]*n

def dfs(x,check):
    #if check[x] != -1:
    #    return
    for i in range(len(ab[x])):
        cho = ab[x][i]
        #print(cho,x)
        if check[cho] != -1:
            continue
        check[cho] = num
        dfs(cho,check)
    
    return

num = 0
for i in range(n):
    #print(i,check[i])
    if check[i] != -1:
        continue
    dfs(i,check)
    num += 1
#print(check)
grp_num = max(check)
grp_size = [0]*(grp_num+1)

for i in range(n):
    grp_size[check[i]] += 1
exit()
for i in range(n):
    hiku = 0
    for j in range(len(cd[i])):
        #print(cd[i],check[i],cd[i][j],check[cd[i][j]])
        if check[cd[i][j]] == check[i]:
            hiku += 1
            #print(hiku,hiku,hiku,hiku,hiku)
    #print(grp_size[check[i]]-len(ab[i])-hiku-1,end=' ')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

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

ab = [[] for j in range(n)]
cd = [[] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
    
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
check = [-1]*n

def dfs(x,check):
    #if check[x] != -1:
    #    return
    for i in range(len(ab[x])):
        cho = ab[x][i]
        #print(cho,x)
        if check[cho] != -1:
            continue
        check[cho] = num
        dfs(cho,check)
    
    return

num = 0
for i in range(n):
    #print(i,check[i])
    if check[i] != -1:
        continue
    dfs(i,check)
    num += 1
#print(check)
grp_num = max(check)
grp_size = [0]*(grp_num+1)

for i in range(n):
    if check[i] == -1:
        continue
    grp_size[check[i]] += 1

for i in range(n):
    hiku = 0
    for j in range(len(cd[i])):
        #print(cd[i],check[i],cd[i][j],check[cd[i][j]])
        if check[cd[i][j]] == check[i]:
            hiku += 1
            #print(hiku,hiku,hiku,hiku,hiku)
    if check[i] == -1:
        print(0)
    else:
        print(grp_size[check[i]]-len(ab[i])-hiku-1,end=' ')
from operator import itemgetter

N,M=map(int,input().split())
PY=[]
P=[[] for i in range(N)]
Pk=[0 for i in range(N)]
ans=[0 for i in range(M)]
for i in range(M):
    PYi=list(map(int,input().split()))
    PY.append(PYi)
    P[PYi[0]-1].append([i,PYi[1]])
    Pk[PYi[0]-1]+=1

for i in range(N):
    P[i]=sorted(P[i], key=itemgetter(1))

for i in range(N):
    for j in range(Pk[PY[i][0]-1]):
        ans[P[PY[i][0]-1][j][0]]=j+1
        
for i in range(M):
    a=format(PY[i][0],'06x')
    b=format(ans[i],'06x')
    print(a+b)

### FIXED CODE ###

from operator import itemgetter

N,M=map(int,input().split())
PY=[]
P=[[] for i in range(N)]
ans=[0 for i in range(M)]
for i in range(M):
    PYi=list(map(int,input().split()))
    PY.append(PYi)
    P[PYi[0]-1].append([i,PYi[1]])

for i in range(N):
    P[i]=sorted(P[i], key=itemgetter(1))

for i in range(N):
    for j in range(len(P[i])):
        ans[P[i][j][0]]=j+1

for i in range(M):
    a=format(PY[i][0],'06d')
    b=format(ans[i],'06d')
    print(a+b)
n=int(input())
n,a=map(int,input().split())
h=list(map(int,input().split()))
list=[]
for hh in h:
  list.append(t-0.006*hh)
ans=[]
for l in list:
  ans.append(abs(a-l))
print(min(ans))
        

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
list=[]
for hh in h:
  list.append(t-0.006*hh)
ans=[]
for l in list:
  ans.append(abs(a-l))
print(ans.index(min(ans))+1)
s = int(input())
w = int(input())
if w >= s:
  print("unsafe")
else:
  print('safe')

### FIXED CODE ###

s, w = map(int, input().split())
if w >= s:
  print('unsafe')
else:
  print("safe")
(n,m),*a=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
for a in a:
 b,a=sorted(map(r:=lambda x:x*(p[x]<0)or r(p[x]),a),key=p.__getitem__)
 if a-b:p[a]+=p[b];p[b]=a
print(sum(i<0for i in p)-2)

### FIXED CODE ###

code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/dsu>" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()
from libc.stdio cimport getchar, printf
cdef inline int read() nogil:
    cdef int b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: return c
        c = c * 10 + b
cdef int n = read(), i
cdef dsu *u = new dsu(n)
for i in range(read()): u.merge(read() - 1, read() - 1)
printf('%lu\n', u.groups().size() - 1)
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve