Harryxun/stf_run huggingface dataset:
import sys

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))

    solve(N)

def solve(N: int):
    N_max = min(N, 1000000000000)
    tmp_list = []
    for i in range(1, N_max):
        for j in range(1, N_max):
            if i*j == N:
                tmp_list.append((i, j))

    if tmp_list:
        answer = tmp_list[0][0] + tmp_list[0][1]

    for i_tp in tmp_list:
        tmp = i_tp[0] + i_tp[1]

        if tmp < answer:
            answer = tmp

    print(answer - 2)
    return

 
if __name__ == "__main__":
    propare()

### FIXED CODE ###

import sys
import math

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))

    solve(N)

def solve(N: int):
    # Symmetry, a<=b, a<=math.sqrt(N)
    N_max = min(N, 1000000000000)
    a_max = int(math.sqrt(N_max))
    tmp_list = []
    for a in range(1, a_max+1):
        if N%a == 0:
            b = int(N/a)
            tmp_list.append((a, b))

    if tmp_list:
        answer = tmp_list[0][0] + tmp_list[0][1]

    for i_tp in tmp_list:
        tmp = i_tp[0] + i_tp[1]

        if tmp < answer:
            answer = tmp

    print(answer - 2)
    return

 
if __name__ == "__main__":
    propare()
import heapq
n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    ab[a-1].append(-b)
heap = []
ans = 0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(heap, j)
    if heap:
        res = heapq.heappop(heap)
        ans += -res
print(ans)

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if m >= a:
        ab[a-1].append(-b)
heap = []
ans = 0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(heap, j)
    if heap:
        res = heapq.heappop(heap)
        ans += -res
print(ans)
import functools
import math

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

for i in range(n):
    city[i] = abs(city[i]-x)

gcd = functools.reduce(math.gcd, city)
print(gcd)

### FIXED CODE ###

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

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

for i in range(n):
    city[i] = abs(city[i]-x)

ans = city[0]
for num in city:
    ans = gcd(ans, num)

print(ans)
import sys
def f0070(A,n,s):
  if n==1:
    if s in A: f=1
    else f=0
    return f
  c=0
  A=sorted(A)
  A1=A[:n][::-1]
  A2=A[-n:]
  N=range(n)
  def f(A):
    return sum([(i+1)*A[i] for i in N])
  if f(A1)<=s<=f(A2):
    for i in range(len(A)):
      b=s-A[i]*n
      c+=f0070(A[:i]+A[i+1:],n-1,b)
  return c

for a in sys.stdin:
  n,s=map(int,a.split())
  print f0070(range(10),n,s)

### FIXED CODE ###

import sys
K=1024
N=331
R=range(K)
B=[1,2,4,8,16,32,64,128,256,512]
C=[0]*K
D=[[0 for i in range(N)]for j in R]

for i in R:
  s=format(i,'b')
  n=s.count('1')
  C[i]=n
  if n==1:D[i][B.index(i)]=1
  else:
    for j in range(len(s)):
      if s[-j-1]=='1':
        dp=n*j
        i2=i-B[j]
        for k in range(N-dp):
          D[i][k+dp]+=D[i2][k]
   
for a in sys.stdin:
  n,s=map(int,a.split())
  x=0
  if s<N:x=sum([D[i][s] for i in R if C[i]==n])
  print x
from collections import Counter
def cmb(n):
    if n < 2:
        return 0
    else:
        return (n * (n-1)) // 2

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

cs = Counter(a)
s = 0

for v in cs.values():
    s += cmb(v)

for a in ls:
    print(s - cmb(c[a]) + cmb(c[a] - 1))

### FIXED CODE ###

from collections import Counter
def cmb(n):
    if n < 2:
        return 0
    else:
        return (n * (n-1)) // 2

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

cs = Counter(ls)
s = 0

for v in cs.values():
    s += cmb(v)

for a in ls:
    print(s - cmb(cs[a]) + cmb(cs[a] - 1))
n = input()
A = list(map(int, input().split()))
for i in range(n):
    if A[i]<0:
        A[i] = -A[i]
if n % 2 == 1:
    print(sum(A)-2*min(A))
else:
    print(sum(A))
            

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(n):
    if A[i]<0:
        A[i] = -A[i]
        count += 1
if count % 2 == 1:
    print(sum(A)-2*min(A))
else:
    print(sum(A))
count = 1

whie (true) :
    x = input().strip()
    if x == '0' :
        break;
    print('Case %s: %s',(count,x))
    count += 1;

### FIXED CODE ###

count = 1

while True :
    x = input().strip()
    if x == '0' :
        break
    print('Case %s: %s'%(count,x))
    count = count + 1;
s = input()
oddone = ''
evenone = ''

for i in range(len(s)):
    if i % 2 ==	1:
        oddone += '1'
        evenone += '0'
    else:
	oddone += '0'
	evenone += '1'

def diffCount(s1, s2):
    count = 0
    if len(s1) != len(s2):
	print('error')
	return

    for i in range(len(s1)):
        if s1[i] != s2[i]:
	    count += 1

    return count

print(min(diffCount(s, oddone), diffCount(s, evenone)))


### FIXED CODE ###

s = input()
oddone = ''
evenone = ''

for i in range(len(s)):
    if i % 2 == 1:
        oddone += '1'
        evenone += '0'
    else:
        oddone += '0'
        evenone += '1'

def diffCount(s1, s2):
    count = 0
    if len(s1) != len(s2):
        print('error')
        return

    for i in range(len(s1)):
        if s1[i] != s2[i]:
            count += 1

    return count

print(min(diffCount(s, oddone), diffCount(s, evenone)))
s,t = input.split()
print(t,s,sep='')

### FIXED CODE ###

s,t = input().split()
print(t, s, sep='')
A, B = map(int, raw_input().split())
cnt = 0
for i in range(A, B+1):
	s = str[i]
	if s[0] == s[4] and s[1] == s[3]:
		cnt = cnt + 1

print cnt

### FIXED CODE ###

A, B = map(int, raw_input().split())
cnt = 0
for i in range(A, B+1):
	s = str(i)
	if s[0] == s[4] and s[1] == s[3]:
		cnt = cnt + 1

print cnt
L,R=map(int,input().split())
if (L-R)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,I*j//2019)
print(ans)
  

### FIXED CODE ###

L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)
i = input(map(int, input().split()))
A = i[0]
B = i[1]

if A-B*2>0;
	print(A-B*2)
  else;
	print(0)
    

### FIXED CODE ###

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

# Input
i = list(map(int, input().split()))

# Process
X = i[0] - i[1]*2

# Output
if X > 0:
    print(X)
else:
    print(0)
S=int(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print('Bad')
else:
    print('Good')

### FIXED CODE ###

S=input()
for i in range(3):
  if S[i]==S[i+1]:
    print('Bad')
    exit()
print('Good')
import math
a,b = input().split()
hoge = int(a + b)
root_hoge = math.sqrt(hoge)
if a / root_hoge == root_hoge:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

import math
a,b = input().split()
hoge = int(a + b)
root_hoge = int(math.sqrt(hoge))
if hoge / root_hoge == root_hoge:
  print('Yes')
else:
  print('No')
return sys.stdin.readline()[:-1]
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
l=[None]*K
a=0
for i in range(K):
    t=0
    l[i]=T[i:N:K]
    for j in l[i]:
        if j=="r":
            if t!=1:
                a+=P
                t=1
            else:
                t=0
        if j=="s":
            if t!=2:
                a+=R
                t=2
            else:
                t=0
        if j=="p":
            if t!=3:
                a+=S
                t=3
            else:
                t=0
print(a)

### FIXED CODE ###

N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
a=0
for i in range(K):
    t=0
    l=T[i:N:K]
    for j in l:
        if j=="r":
            if t!=1:
                a+=P
                t=1
            else:
                t=0
        if j=="s":
            if t!=2:
                a+=R
                t=2
            else:
                t=0
        if j=="p":
            if t!=3:
                a+=S
                t=3
            else:
                t=0
print(a)
N = int(input())
A = [int(l) for l in input().split()]

count = 0
while True:
    for i in range(N):
        if A[i]/2** k % 2 !=0:
            break
    else:
        count += 1    
        continue
    break

print(count)

### FIXED CODE ###

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

min_a = min(a_list)
count = 0
while min_a % 2 == 0:
    min_a /= 2
    count += 1
#print(count)
for a in a_list:
    if a % 2 ** count != 0:
        a_count = 0
        while a % 2 == 0:
            a /= 2
            a_count += 1
        count = a_count

print(count)
a = int(input())
b = int(input())

if(a == 1 & b == 1)
	pass

### FIXED CODE ###

x, y = map(int, input().split(" "))
 
total = 0
 
rewards = {1: 300000, 2: 200000, 3: 100000}

x1 = rewards[x] if (x <= 3) else 0
y1 = rewards[y] if (y <= 3) else 0
 
if (x == 1 and y ==  1):
  total += 400000
if (x1 != None):
  total += x1
if (y1 != None):
  total += y1
 
print(total)
N, M = map(int, input().split())
table = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    table[a-1].append(b-1)

visit = [False] * N
visit2 = [False] * N
g = []


def dfs(v):
    g.append(v)
    if visit[v]:
        return True
    visit[v] = True
    visit2[v] = True
    for u in table[v]:
        if dfs(u):
            return True
    g.pop()
    visit[v] = False
    return False


for i in range(N):
    g = []
    if not visit2[i]:
        if dfs(i):
            break
else:
    print(-1)
    exit()

print(*[v+1 for v in g[g.index(g[-1]):-1]], sep="\n")


### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10000)
N, M = map(int, input().split())
table = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    table[a-1].append(b-1)

visit = [False] * N
visit2 = [False] * N
g = []


def dfs(v):
    g.append(v)
    if visit[v]:
        return True
    visit[v] = True
    visit2[v] = True
    for u in table[v]:
        if dfs(u):
            return True
    g.pop()
    visit[v] = False
    return False


for i in range(N):
    g = []
    if not visit2[i]:
        if dfs(i):
            break
else:
    print(-1)
    exit()
print(0)
# ans = [v+1 for v in g[g.index(g[-1]):-1]]
# print(len(ans))
# print(*ans, sep="\n")
N = int(input())
S = str(input())
X = [];Bit = 0
for i in range(N):
  if S[i] == "1":
    Bit += 1
  X.append(int(S[i]))
#print(X)
MAX = 21
small = [-1 for _ in range(MAX)]
small[0] = 0; small[1] = 1; small[2] = 1; small[3] = 2
for i in range(4,MAX):
  ret = 0; target = i*1
  while i > 0:
    cnt = 0
    for j in range(i.bit_length()):
      if (i>>j)&1 == 1:
        cnt += 1
    i = i%cnt
    #print(i,target,cnt)
    ret += 1
    if small[i] != -1:
      ret += small[i]
      break

  small[target] = ret
#print(small)
Num = int(S, 2)
#print(Num)
ans = []
for i in range(N):
  keta = N-1-i
  if X[i] == 1:
    temp = Num - pow(2,keta)
    btemp = Bit -1 
  else:
    temp = Num + pow(2,keta)
    btemp = Bit + 1
  nokori = temp%btemp
  ret = small[nokori] + 1 #最初の一回
  ans.append(ret)
print(*ans,sep="\n")

### FIXED CODE ###

from collections import deque
N = int(input())
X = str(input())
X = list(X)
#motokosu = X.count("1")
motokosu = 0
only = float("inf")
for i in range(N):
  if X[i] == "1":
    motokosu += 1
    only = i
if motokosu != 1:
  only = float("inf")
#print(motosuji,motokosu)
MAX = 2*pow(10,5)+10
base = [0 for _ in range(MAX)] #0から19までの答えを保存
for i in range(MAX):
  now = i
  temp = 0
  while now != 0:
    ones = 0
    tnow = now*1
    for t in range(len(bin(now))-2):
      if (now>>t)&1 == 1:
        ones += 1
    #print(i,ones,now)
    now = now%ones
    #print(now,base[now])
    base[i] = base[now] + 1
    break
    #temp += 1
  #base[i] = temp
#print(base)
A = []
pkosu = motokosu+1
mkosu = motokosu-1
P = deque([])
M = deque([])
ptemp = 1; mtemp = 1
for i in range(N):
  P.appendleft(ptemp%pkosu)
  ptemp = ptemp*2%pkosu
  if mkosu < 1:
    M.appendleft(0)
  else:
    M.appendleft(mtemp%mkosu)
    mtemp = mtemp*2%mkosu

pmotosuji = 0; mmotosuji = 0
for i in range(N):
  if X[i] == "1":
    pmotosuji = (pmotosuji+P[i])%pkosu
    if mkosu >= 1:
      mmotosuji = (mmotosuji+M[i])%mkosu
#print(P,M,pkosu,mkosu,pmotosuji,mmotosuji)

for i in range(N): #i桁目を入れ替える
  if only == i:
    print(0)
    continue
  if X[i] == "0": #その桁が0なら1にする
    kosu = motokosu + 1
    suji = (pmotosuji + P[i])%kosu
  else: #その桁が1なら0にする
    kosu = motokosu - 1
    if kosu == 0:
      suji = -1
    else:
      suji = (mmotosuji - M[i])%kosu
    
  #print(suji,kosu)
  #if suji == 0:
  #  ans = 0
  if suji == -1:
    ans = 1
  else:
    nxt = suji%kosu
    ans = 1+base[nxt]
  #A.append(ans)
  print(ans)

#print(*A,sep="\n")
#print(2**17)
#print(motokosu)
n, k = map(int, input().split(" "))
a = [-1] + list(map(int, input().split(" ")))

i = 1
head = []
used = {}
roop = []

inte=False
index = 0
for _ in range(k):
    index += 1
    i = a[i]
    if i in used:
        head = [ k for k, v in used.items() if v < used[i]]
        roop = [ k for k, v in sorted(used.items())]
        inte =True
        break
    else:
        used[i] = index

print(head, roop)

if inte:
    if len(head) >= k:
        print(head[k-1])
    else:
        x = (k - 1 - len(head)) % len(roop)
        print(roop[x])
else:
    print(used[k-1])

### FIXED CODE ###

import sys

n, k = map(int, input().split(" "))
a = [-1] + list(map(int, input().split(" ")))

i = 1
head = []
used = {}
roop = []

index = 0
for _ in range(k):
    index += 1
    i = a[i]
    if i in used:
        head = [ k for k, v in sorted(used.items(), key=lambda x:x[1]) if v < used[i]]
        roop = [ k for k, v in sorted(used.items(), key=lambda x:x[1]) if v >= used[i]]
        if len(head) >= k:
            print(head[k-1])
        else:
            x = (k - 1 - len(head)) % len(roop)
            print(roop[x])
            sys.exit()
    else:
        used[i] = index

print([ k for k, v in sorted(used.items(), key=lambda x:x[1])][k-1])
N = int(input())
S = [s for s in input()]
ans = 0
for i in range(1000):
    v = str(i).zfill(3)
    idx = 0
    for j, s in enumerate(S):
        if v[idx] == s:
            idx += 1
            if v[idx] not in S[j+1:]:
                break
        if idx == 3:
            ans += 1
            break
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
for i in range(1000):
    v = str(i).zfill(3)
    idx = 0
    c = 0
    idx_now = 0
    for j in range(3):
        idx = S[idx_now:].find(v[j])
        if idx == -1:
            break
        else:
            idx_now += idx + 1
            c += 1
    if c == 3:
        ans += 1
print(ans)
import math

a, b, c, d = map(int, input().split())
divc = b // c - a // c
if a % c == 0:
    divc += 1
divd = b // d - a // d
if a % d == 0:
    divd += 1
    
lcm = c * d / math.gcd(c, d)
divlcm = b // lcm - a // lcm
if a % lcm == 0:
    divlcm += 1


div_or = divc + divd - divlcm
print(int(b - a + 1 - div_or))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

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

a, b, c, d = map(int, input().split())
divc = b // c - a // c
if a % c == 0:
    divc += 1
divd = b // d - a // d
if a % d == 0:
    divd += 1
    
lcm = c * d // gcd(c, d)
divlcm = b // lcm - a // lcm
if a % lcm == 0:
    divlcm += 1


div_or = divc + divd - divlcm
print(int(b - a + 1 - div_or))
N, M = map(int, input().split())
S = input()
T = input()

from math import gcd

def solve(N,M,S,T):
    g = gcd(N,M)
    for i in range(g):
        if S[N//g*i]!=T[M//g*i]:
            return -1
    ans = N*M//g
    return ans
print(solve(N,M,S,T))

### FIXED CODE ###

N, M = map(int, input().split())
S = input()
T = input()

from fractions import gcd

def solve(N,M,S,T):
    g = gcd(N,M)
    for i in range(g):
        if S[N//g*i]!=T[M//g*i]:
            return -1
    ans = N*M//g
    return ans
print(solve(N,M,S,T))
a,b=map(int, input().split())
s=list(input())

if s[a]!="-":
  print("No")
  exit()
  
for i in range(a):
  if s[i]=="-":
    print("No")
    exit()

for i in range(b):
  if s[b+i]=="-":
    print("No")
    exit()

print("Yes")

### FIXED CODE ###

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

if s[a]!="-":
  print("No")
  exit()
  
for i in range(a):
  if s[i]=="-":
    print("No")
    exit()

for i in range(b):
  if s[a+1+i]=="-":
    print("No")
    exit()

print("Yes")
n=int(input())
a=list(map(int,input().split()))
b=[[a[i],i] for i in range(n)]
b.sort()
for i in b:
  print(i[i]+1,end=" ")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[[a[i],i] for i in range(n)]
b.sort()
for i in b:
  print(i[1]+1,end=" ")
from collections import defaultdict

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

D = defaultdict(set)
R = {}
for _ in range(M):
  a, b = map(int, input().split())
  if a in R:
    if b in R:
      aa, bb = R[a], R[b] 
      if aa == bb:
        pass
      else:
        for x in D[bb]:
          R[x] = aa
        D[aa] |= D[bb]
        del D[bb]
    else:
      R[b] = R[a]
      D[R[a]].add(b)
  else:
    if b in R:
      R[a] = R[b]
      D[R[b]].add(a)
    else:
      R[a] = a
      R[b] = a
      D[a].add(b)

print(max(len(x) for x in D.values()) + 1)

### FIXED CODE ###

from collections import defaultdict

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

D = defaultdict(set)
R = {}
for _ in range(M):
  a, b = map(int, input().split())
  if a in R:
    if b in R:
      aa, bb = R[a], R[b] 
      if aa == bb:
        pass
      else:
        if len(D[aa]) < len(D[bb]):
          aa, bb = bb, aa
        for x in D[bb]:
          R[x] = aa
        D[aa] |= D[bb]
        del D[bb]
    else:
      R[b] = R[a]
      D[R[a]].add(b)
  else:
    if b in R:
      R[a] = R[b]
      D[R[b]].add(a)
    else:
      R[a] = a
      R[b] = a
      D[a].add(a)
      D[a].add(b)

print(max(len(x) for x in D.values()) if D else 1)
X,N = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    A = []
    B = []
    for i in range(101):
        if i not in P and i <= X:
            A.append(i)
        elif i not in P and i > X:
            B.append(i)
    A = sorted(A,reverse=True)
    B = sorted(B)
    a = abs(X - A[0])
    b = (B[0] - X)
    if a <= b:
        print(A[0])
    else:
        print(B[0])

### FIXED CODE ###

X,N = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    for i in range(100):
        if not X - i in P:
            a = X - i
            break
        if not X + i in P:
            a = X + i
            break
    print(a)
N = int(input())
H= [int(s) for s in input().split()]

#print(N,H)

t=0
k=0

for i in range(1,N):
#  print("i="+str(i))
  if H[i]-H[i-1]<=0:
    k=k+1
#    print("k="+str(k))
    if k > t:
      t=k
#      print("t="+str(t))
  else:
    k=0
    continue
    
print(k)


### FIXED CODE ###

S=list(input())
T=list(input())

k=0
for i in (range(3)):
  if S[i]==T[i]:
    k=k+1

print(k)
alpha1='abcdefghijklmnopqrstuvwxyz'
alpha2='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n,k = list(map(int,input().split(" ")))
s = input()

for i in range(26):
  if alpha2[i] == s[k-1]:
    t = i
    break
s[k-1] = alpha1[t]
print(s)


### FIXED CODE ###

alpha1='abcdefghijklmnopqrstuvwxyz'
alpha2='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n,k = list(map(int,input().split(" ")))
s = list(input())

for i in range(26):
  if alpha2[i] == s[k-1]:
    t = i
    break
s[k-1]=alpha1[t]
for i in range(n):
  print(s[i],end="")
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([int(i) for i in input().split()])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(l):
    print(" ".join([str(s) for s in C[ni]]))

### FIXED CODE ###

n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))
a=int(input())
b,c = map(int,input.split())
s=input()
print({} {}.format(a+b+c,s))

### FIXED CODE ###

s=input()
t=input()
if t[:-1]==s:
  print("Yes")
else:
  print("No")
s, w = (int(x) for x in input().split())
if s <= w:
    print('unsafe')
else:
    print('safe')

### FIXED CODE ###

s, w = map(int, input().split())
if s <= w:
    print('unsafe')
else:
    print('safe')
# ABC 067 D
N = int(input())
G = [[] for k in range(N+1)]
for k in range(N-1):
    a, b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)

kyori1 = [100000 for k in range(N+1)]
kyori2 = [100000 for k in range(N+1)]

def dfs1(now, dist):
    for tsugi in G[now]:
        if kyori1[tsugi] == 100000:
            kyori1[tsugi] = dist + 1
            dfs1(tsugi, dist+1)

def dfs2(now, dist):
    for tsugi in G[now]:
        if kyori2[tsugi] == 100000:
            kyori2[tsugi] = dist + 1
            dfs2(tsugi, dist+1)

kyori1[1] = 0
dfs1(1,0)

kyori2[N] = 0
dfs2(N,0)

s = 0
f = 0
for k in range(1,N+1):
    if kyori1[k] <= kyori2[k]:
        f += 1
    else:
        s += 1

print("Fennec" if f > s else "Snuke")


### FIXED CODE ###

# ABC 067 D
import sys
sys.setrecursionlimit(200000)

N = int(input())
G = [[] for k in range(N+1)]
for k in range(N-1):
    a, b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)

kyori1 = [100000 for k in range(N+1)]
kyori2 = [100000 for k in range(N+1)]

def dfs1(now, dist):
    for tsugi in G[now]:
        if kyori1[tsugi] == 100000:
            kyori1[tsugi] = dist + 1
            dfs1(tsugi, dist+1)

def dfs2(now, dist):
    for tsugi in G[now]:
        if kyori2[tsugi] == 100000:
            kyori2[tsugi] = dist + 1
            dfs2(tsugi, dist+1)

kyori1[1] = 0
dfs1(1,0)

kyori2[N] = 0
dfs2(N,0)

s = 0
f = 0
for k in range(1,N+1):
    if kyori1[k] <= kyori2[k]:
        f += 1
    else:
        s += 1

print("Fennec" if f > s else "Snuke")
mod = 1000000007
n = int(input())
s = input()
abets = “abcdefghijklmnopqrstuvwxyz”
counts = []
for c in abets:
  counts.append(s.count(c))
ans = 0
for ptn in range(2** len(abets)):
  bin_str = format(ptn, ‘b’)
  subans = 1
  for i, b in enumerate(bin_str[::-1]):
    if b == ‘1’:
      subans = (subans * counts[i]) % mod
  ans = (ans + subans) % mod
print(ans)

### FIXED CODE ###

mod = 1000000007
n = int(input())
s = input()
abets ="abcdefghijklmnopqrstuvwxyz"
counts = []
for c in abets:
  counts.append(s.count(c))
ans = 0
for cnt in counts:
  if cnt != 0:
    ans = (ans + ans*cnt + cnt) % mod
print(ans)