Harryxun/stf_run huggingface dataset:
import numpy as np
n,m = map(int,input().split())
lis = list(map(int,input().split()))
path = [[] for i in range(n)]

for i in range(m):
    x,y = map(int,input().split())
    x -= 1;y -= 1
    path[x].append(y)
    path[y].append(x)

gone = np.array([-1] * n)
numberindex = set()
ans = 0

for i in range(n):
    if gone[i] == -1:
        now = [i]
        realnumber = np.array([0] * n)
        numberindex.add(i)
        while now:
            a = now.pop(0)
            gone[a] = 1
            numberindex.add(a)
            realnumber[lis[a]-1] = 1
            for go in path[a]:
                if gone[go] == -1:
                    now.append(go)
                    gone[go] = 1
        for num in numberindex:
            if realnumber[num] == 1:
                ans += 1
        numberindex = set()
print(ans)

### FIXED CODE ###

import numpy as np
n,m = map(int,input().split())
lis = list(map(int,input().split()))
path = [[] for i in range(n)]

for i in range(m):
    x,y = map(int,input().split())
    x -= 1;y -= 1
    path[x].append(y)
    path[y].append(x)

gone = np.array([-1] * n)
numberindex = set()
realnumber = set()
ans = 0

for i in range(n):
    if gone[i] == -1:
        now = [i]
        while now:
            a = now.pop(0)
            gone[a] = 1
            numberindex.add(a)
            realnumber.add(lis[a]-1)
            for go in path[a]:
                if gone[go] == -1:
                    now.append(go)
                    gone[go] = 1
        ans += len(realnumber & numberindex)
        realnumber,numberindex = set(),set()
print(ans)
N, K = map(int, input().split())
d = []
A = []
safe = []
ubsafe = []
for k in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

for _ in range(K-1):
    for p in range(d[K-1]-1):
        safe.append(A[_][p])
        
L = len(list(set(safe)))
print(N-L)


### FIXED CODE ###

N, K = map(int, input().split())
d = []
A = []

for k in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

Alist = [e for row in A for e in row]
        
L = len(list(set(Alist)))
print(N-L)
a, b = input().split()
if a > 8 or b > 8: print(":(")
else: print("Yay!")

### FIXED CODE ###

a, b = map(int, input().split())
if a>8 or b>8: print(":(")
else: print("Yay!")
n=input()
n=int(n)
if(n%10==7)
  print("Yes")
  else
    print("No")

### FIXED CODE ###

n=input()
n=int(n)
og=n
flag=0
while(n>0):
    d=n%10
    n=n//10
    if(d==7):
        flag=flag+1
        
if(flag>0):
    print("Yes")
else:
    print("No")
n = int(input())
a = list(map(int, input().split()))

x = max(a)
m = x/2
a.remove(x)
a.sort()
ans = 10000

for i in a:
    y = abs(i - m)
    if ans >= y:
        ans = y
    else:
        break    
    z = i
      
print(x, z)

### FIXED CODE ###

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

x = max(a)
m = x/2
a.remove(x)
a.sort()
ans = x

for i in a:
    y = abs(i - m)
    if ans >= y:
        ans = y
    else:
        break    
    z = i
      
print(x, z)
n = int(input())
a = [int(input()) for i in range(n)]

myset = {}
for i in a:
    if i in myset:
        myset.remove(i)
    else:
        myset.add(i)
ans = len(myset)

print(ans)

### FIXED CODE ###

n = int(input())

myset = set()
for i in range(n):
    a = int(input())
    if a in myset:
        myset.remove(a)
    else:
        myset.add(a)
ans = len(myset)

print(ans)
N, M = [int(i) for i in input().split()]
A = {int(input()) for _ in range(M)}

dp = [0] * 10010
dp[0] = 1
dp[1] = 0 if 1 in A else 1
for i in range(N):
    if i+2 in A:
        continue
    dp[i+2] = dp[i] + dp[i+1]

print(dp[N] % 1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])

dp = [0, 1]
for i in range(N):
    if i+1 in A: dp.append(0)
    else: dp.append(dp[i]+dp[i+1])
print(dp[N+1]%1000000007)
N = int(input())
a = list(map(int, input().split()))
a.reverse()

def search(x):
    n = 1
    res = 0
    while True:
        nx = n*x
        if nx >= N:
            break
        res += boxes[nx]
        n += 1
    return res%2


boxes = [0]*N
for i, ai in enumerate(a):
    i = N-i
    eo = search(i)
    if ai!=eo:
        boxes[i]=1

ans=[]
for i, box in enumerate(boxes):
    if box==1:
        ans.append(i)

if ans==[]:
    print(0)
else:
    print(*ans)

### FIXED CODE ###

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

M = 0
boxes = [0]*N
for i in reversed(range(N)):
    num_balls = 0
    for k in range(i, N, i+1):
        num_balls += boxes[k]
    if num_balls%2 != a[i]:
        boxes[i] = 1
        M += 1

print(M)
for i in range(N):
    if boxes[i]==1:
        print(i+1)
A,B=[int(e) for e in input()]
print(max([A+A-1,A+B,B+B-1]))



### FIXED CODE ###

A,B=[int(e) for e in input().split(' ')]
print(max([A+A-1,A+B,B+B-1]))
X , Y = map(int , input().split())

if X > Y:
    ma = X
    mi = Y
else:
    ma = Y
    mi = X

for i in range(mi):
    a = X - 3*i
    b = Y - 3*i
    if a == 2 * b or b == 2 * a:
        import math
        pattern = math.factorial(2*i + ((ma - 3*i)//2)) // (i * (i + ((ma - 3*i)//2)))
        print(pattern % (10**9 + 7))
        break
        
if a != 2 * b and b != 2 * a:
    print(0)

### FIXED CODE ###

r = int(input())

print(r**2)
a,b,c=map(int,input().split())
total=a+b+c
if total%2=0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c = map(int, input().split())
if max(a,b,c)*2==a+b+c:
    print("Yes")
else:
    print("No")
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

MOD = 1000000007
n, k = map(int, input().split())
r = n-k

kk = []
rr = []
for i in range(k):
	kk.append(cmb(k-1,i)%MOD)

for i in range(r):
	rr.append(cmb(r-1,i)%MOD)
rr.append(0);rr.append(0)

for i in range(k):
	if i <= r + 1:
		print(kk[i] * (rr[i-1] + rr[i]*2 + rr[i+1]))
	else:
		print(0)


### FIXED CODE ###

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

MOD = 1000000007
n, k = map(int, input().split())
r = n-k

kk = []
rr = []
for i in range(k):
	kk.append(cmb(k-1,i)%MOD)

for i in range(r):
	rr.append(cmb(r-1,i)%MOD)
rr.append(0);rr.append(0);rr.append(0)

if r == 0:
	print(1)
	for i in range(k-1):
		print(0)
else:
	for i in range(k):
		if i <= r + 1:
			print((kk[i] * (rr[i-1] + rr[i]*2 + rr[i+1]))%MOD)
		else:
			print(0)
import sys
sys.setrecursionlimit(10**6)

l, r = map(int, input().split())

MOD = 2019

#n = 2019
#pf = {}
#
#for i in range(2,int(n**0.5)+1):
#    while n % i == 0:
#        pf[i] = pf.get(i,0) + 1
#        n //= i
#if n > 1: pf[n] = 1
#print(pf)
## 2019=3*673

import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:
    if l_mod < r_mod:
    	li = [i for i in range(l_mod, r_mod+1)]
    	ans = 2018
    	for v in itertools.combinations(li, 2):
      	ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

l, r = map(int, input().split())

MOD = 2019

#n = 2019
#pf = {}
#
#for i in range(2,int(n**0.5)+1):
#    while n % i == 0:
#        pf[i] = pf.get(i,0) + 1
#        n //= i
#if n > 1: pf[n] = 1
#print(pf)
## 2019=3*673

import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:
    if l_mod <= 3 <= r_mod and l_mod <= 673 <= r_mod:
        ans = 0
    elif l_mod < r_mod:
        li = [i for i in range(l_mod, r_mod+1)]
        ans = 2018
        for v in itertools.combinations(li, 2):
            ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)
n = int(input())
s = input()
Q = int(input())
target = ord("a")
k = [[0 for _ in range(n)] for _ in range(26)]
c = [0 for _ in range(n)]

for i in range(n):
	henkou = ord(s[i])-target
	k[henkou][i] += 1
	c[i] = henkou

class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, a):
		self.bitlen = len(a)+1
		self.bit = [0]*(len(a)+1)
		for i, j in enumerate(a):
			self.add(i, j)

b = [BIT(k[i]) for i in range(26)]

for _ in range(Q):
	q = input()
	if q[0] == "1":
		qa = int(q[2])
		hen = ord(q[4])-target
		b[hen].add(qa-1, 1)
		b[c[qa-1]].add(qa-1, -1)
		c[qa-1] = hen
	else:
		ans = 0
		qta = int(q[2])
		qtb = int(q[4])
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans)

### FIXED CODE ###

n = int(input())
stmp = list(input())
Q = int(input())
target = ord("a")
s = [ord(stmp[i])-target for i in range(n)]

class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1)

b = [BIT(n) for i in range(26)]
for i in range(n):
	b[s[i]].add(i, 1)

for _ in range(Q):
	q,qtmpa,qtmpb = input().split()
	if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans)
s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(s+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        s=s[:i-1]+[s[-1]]
        print(''.join(s))
        exit()
else:print(-1)

### FIXED CODE ###

s=list(input())
al=[chr(ord('a') + i) for i in range(26)]
al=[i for i in al if i not in s]
if al:
    print(''.join(s)+al[0])
    exit()
for i in range(25,0,-1):
    if s[i-1]<s[i]:
        a=[j for j in s[i-1:] if s[i-1]<j]
        s=s[:i-1]+[sorted(a)[0]]
        print(''.join(s))
        break
        exit()
else:print(-1)
k,s = map(int,input().split())
count = 0
for i in range(k+1):
    for j in range(k+1):
        if s-i-j <= k:
            count += 1
print(count)


### FIXED CODE ###

line = input()
print(line.replace(","," "))
W, H, x, y = map(int, raw_input().split())
int mul = 0
if x*2 == W and y*2 == H:
 mul = 1
A = W * H / 2.0
print '%f %d' % (A, mul)

### FIXED CODE ###

W, H, x, y = map(int, raw_input().split())
mul = 0
if x*2 == W and y*2 == H:
    mul = 1
A = W * H / 2.0
print '%f %d' % (A, mul)
k = int(input())
s = input()

slist = list(s)
if len(slist) > k:
  l = ''
  for i in range(k):
    k += slist[i]
  print('...' + l)
else:
  print(s)


### FIXED CODE ###

k = int(input())
s = input()

slist = list(s)
if len(slist) > k:
  l = ''
  for i in range(k):
    l += slist[i]
  print(l + '...')
else:
  print(s)
w, h, x, y = map(int, input().split())

x1 = w - x
y1 = h - y

s = w * h / 2
s1 = x * h / 1
s2 = x1 * h / 1
s3 = y * w / 1 
s4 = y1 * w / 1

if s == s1:
	ans = s1
elif s == s2:
	ans = s2
elif s == s3:
	ans = s3
elif s == s4:
	ans = s4

cnt = 0

if s1 == ans:
	cnt += 1
if s2 == ans:
	cnt += 1
if s3 == ans:
	cnt += 1
if s4 == ans:
	cnt += 1

print(ans, end=" ")
if (cnt > 1):
	print(1)
else:
	print(0)



### FIXED CODE ###

w, h, x, y = map(int, input().split())

cnt = 0
if x == w / 2 and y == h / 2:
	cnt = 1

print(w * h / 2, cnt)
import sys

args = sys.argv

num = args[0]
slimes = args[1]

tmp = []
for i in range(0,len(smiles)):
  if len(tmp): 
  	if slimes[i] == slimes[i+1] and slimes[i] != tmp[-1]:
  		tmp.append(slimes[i])
  else:
    if slimes[i] == slimes[i+1]:
 		tmp.append(slimes[i])

print(len(tmp))    

### FIXED CODE ###

if __name__ == "__main__":
  num = input()
  slimes = input()

  tmp = []
  for i in range(0,len(slimes)):
    if len(tmp):
      if slimes[i] != tmp[-1]:
          tmp.append(slimes[i])
    else:
      tmp.append(slimes[i])
  print(len(tmp))
s = input()
flag = 0
for i in len(range(s)):
  if s[i]=="C":
    flag=1
  if s[i]=="F" and flag==1:
    flag=2
if flag>1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
flag = 0
for i in range(len(s)):
  if s[i]=="C":
    flag=1
  if s[i]=="F" and flag==1:
    flag=2
if flag>1:
  print("Yes")
else:
  print("No")
s = input().split()
a = int(s[0])
b = int(s[1])
if a/2 != int(a/2) and b/2 != int(b/2):
  print(Odd)
else:
  print(Even)

### FIXED CODE ###

s = input().split()
a = int(s[0])
b = int(s[1])
if (a*b)%2 == 0:
  print('Even')
else:
  print('Odd')
a=sorted(list(input()))
print(int(a[0])+int(a[1]))

### FIXED CODE ###

a=sorted(list(input().split()))
print(int(a[0])+int(a[1]))
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = stdin.readline().rstrip()
    K = II() - 1
    ans = []
    for i in range(len(s)):
        for k in range(K):
            b = s[i:i + k + 1]
            ans.append(b)
    ans.sort()
    ans = list(set(ans))
    print(ans[K])
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = stdin.readline().rstrip()
    K = II() - 1
    ans = []
    for i in range(len(s)):
        for k in range(K+1):
            b = s[i:i + k + 1]
            ans.append(b)
    ans = list(set(ans))
    ans.sort()
    print(ans[K])
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()
from collections import defaultdict

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

loop = [0]
town = 0
visited = defaultdict(lambda: None)
visited[town] = 0

for i in range(1, k):
    town = a[town]
    if visited[town] != None:
        offset = visited[town]
        period = i - offset 
        break
    else:
        loop.append(town)
        visited[town] = i

print(loop[offset+((k-offset)%period)]+1)

### FIXED CODE ###

from collections import defaultdict

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

loop = [0]
town = 0
visited = defaultdict(lambda: None)
visited[town] = 0

period = 0
for i in range(1, k+1):
    town = a[town]
    if visited[town] != None:
        offset = visited[town]
        period = i - offset 
        break
    else:
        loop.append(town)
        visited[town] = i

if period == 0:
    print(town+1)
else:
    print(loop[offset+((k-offset)%period)]+1)
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N=int(input())

p=[int(input()) for _ in range(N)]

for i in range(N):
	pay+=p[i]

print(pay-max(p)//2)

### FIXED CODE ###

import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N=int(input())
pay=0
p=[int(input()) for _ in range(N)]

for i in range(N):
	pay+=p[i]

print(pay-max(p)//2)
a = [False,False,False,False]
for x in input().split():
  if(x == 1):
    a[0] =True
  else if(x == 9):
    a[1] = True
  else if(x == 4):
    a[2] = True
  else if(x == 7):
    a[3] = True

all = True
for x in a:
  all &= x

print('YES' if all else 'NO')


### FIXED CODE ###

a = [False,False,False,False]
for x in input().split():
  x = int(x)
  if(x == 1):
    a[0] = True
  elif(x == 9):
    a[1] = True
  elif(x == 4):
    a[2] = True
  elif(x == 7):
    a[3] = True
 
all = True
for x in a:
  all &= x
 
print('YES' if all else 'NO')
import sys
import numpy as np

input = lambda: sys.stdin.readline().rstrip()

def solve(a):
    # a_max = max(a)
    # idx_max = a.index(a_max)
    idx_max = a.argmax()
    a_max = a[idx_max]
    return ((len(a) - 1 - idx_max) * a_max) - sum(a[idx_max + 1:]), idx_max

def solve2(a):
    idx_start = 0
    sum_a = 0
    ans = 0
    len_a = len(a)
    for i in range(1, len_a):
        if a[idx_start] < a[i]:
            # return ((i - 1) * a[0]) - sum_a, i
            ans += ((i - 1) * a[idx_start]) - sum_a
            idx_start = i
            sum_a = 0
        else:
            sum_a += a[i]
            if i == len_a - 1:
                ans += ((i - idx_start) * a[idx_start]) - sum_a
    return ans

def main():
    n = int(input())
    a = np.array(list(map(int, input().split())))
    ans = 0
    # while(1):
    #     k, idx_max = solve2(a)
    #     ans += k
    #     if idx_max == len(a):
    #         break
    #     a = a[idx_max:]
    ans = solve2(a)
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    idx_start = 0
    sum_a = 0
    ans = 0
    cnt = 0
    len_a = len(a)

    for i in range(1, len_a):
        if a[idx_start] < a[i]:
            ans += (cnt * a[idx_start]) - sum_a
            idx_start = i
            sum_a = 0
            cnt = 0
        else:
            sum_a += a[i]
            cnt += 1
            if i == len_a - 1:
                ans += (cnt * a[idx_start]) - sum_a
    print(ans)
if __name__ == '__main__':
    main()
N,M=map(int,input().split())
s=int(input())
S=sum(s)
if sorted(s)[-1:-M]<S/(4*M):
    print('No')
else:
    print('Yes')


### FIXED CODE ###

x,y = map(int,input().split())
A=list(map(int,input().split()))
T=sum(A)
a=0
for i in range(x):
  if A[i]>=T/(4*y):
    a+=1
if a>=y:
    print('Yes')
else:
    print('No')
x=input()
if x="A":
  print("T")
if x="T":
  print("A")
if x="G":
  print("C")
else:
  print("G")

### FIXED CODE ###

x=input()
if x=="A":
  print("T")
if x=="T":
  print("A")
if x=="G":
  print("C")
if x=="C":
  print("G")
N=input()
print((1+int(N/1000))*1000-N)

### FIXED CODE ###

print((10000-int(input()))%1000)
N = int(input())
for i in range(N)
    if int(input())%2 != 0:
        print("first")
        exit()
print('second')

### FIXED CODE ###

N = int(input())
for i in range(N):
    if int(input())%2 != 0:
        print("first")
        exit()
print('second')
import math

N=int(input())
A=[int(input()) for _ in range(N)]
#print(A)

B=0
for a in A:
  B^=a

C=[]
D=[0]*30
for a in A:
  C.append(bin(a^(a-1))[2:])
#print(C)
for c in C:
  D[len(c)]=1
#print(D)

ans=0
while B:
  #print(B,bin(B))
  if D[len(bin(B)[2:])]:
    B^=2**len(bin(B)[2:])-1
    ans+=1
  else:
    ans=-1
    break
print(ans)  

### FIXED CODE ###

import math

N=int(input())
A=[int(input()) for _ in range(N)]
#print(A)

B=0
for a in A:
  B^=a

C=[]
D=[0]*100
for a in A:
  C.append(bin(a^(a-1))[2:])
#print(C)
for c in C:
  D[len(c)]=1
#print(D)

ans=0
while B:
  #print(B,bin(B))
  if D[len(bin(B)[2:])]:
    B^=2**len(bin(B)[2:])-1
    ans+=1
  else:
    ans=-1
    break
print(ans)
N,W = map(int, input().split())


w=[0 for i in range(N)]
v=[0 for i in range(N)]

Wsum = [0 for i in range(N+1)]
Vsum = [0 for i in range(N+1)]

for i in range(N):
    w,v = map(int, input().split())

for i in range(N):
    Wsum[i+1] = Wsum[i] + w[i+1]
    Vsum[i+1] = Vsum[i] + v[i+1]

w.insert(0,"0")
v.insert(0,"0")




Wmin = min(w)

nap_memo ={}

def nap(i,W2):
    kagi = str(i) + ':' +str(W2)
    if kagi in nap_memo:
        return nap_memo[kagi]
    elif i ==0:
        r=0
    elif W2<Wmin:
        r=0
    elif W2 < Wmin:
        r=0
    elif W2 < w[i]:
        r=nap(i-1,W2)
    elif Wsum[i]<=W2:
        r=Vsum[i]
    else:
        r=max( nap(i-1,W2-w[i])+v[i],nap(i-1,W2))
        
    nap_memo[kagi]=r
    return r

print(nap(N,W))
        

### FIXED CODE ###


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


w=[0 for i in range(N)]
v=[0 for i in range(N)]

Wsum = [0 for i in range(N+1)]
Vsum = [0 for i in range(N+1)]

for i in range(N):
    w[i],v[i] = map(int, input().split())
    


Wmin = min(w)    
w.insert(0,"0")
v.insert(0,"0")
for i in range(N):
    Wsum[i+1] = Wsum[i] + w[i+1]
    Vsum[i+1] = Vsum[i] + v[i+1]



nap_memo ={}

def nap(i,W2):
    kagi = str(i) + ':' +str(W2)
    if kagi in nap_memo:
        return nap_memo[kagi]
    elif i ==0:
        r=0
    elif W2<Wmin:
        r=0
    elif W2 < w[i]:
        r=nap(i-1,W2)
    elif Wsum[i]<=W2:
        r=Vsum[i]
    else:
        r=max( nap(i-1,W2-w[i])+v[i],nap(i-1,W2))
        
    nap_memo[kagi]=r
    return r

print(nap(N,W))
a,b=map(int,input().split())
print("H" if a==b else "D")

### FIXED CODE ###

a,b=input().split()
print("H" if a==b else "D")
n, m, x, y = map(int, input().split())
if x>y :
    print('War')
else:
    X = sorted(list(map(int, input().split())))
    Y = sorted(list(map(int, input().split())))
    for i in range(x+1, y+1):
        if X[-1]<i and i <= Y[0] and x < i and i <= y:
            print('No War')
            break
        else :
            a += 1
    if a == y-x:
        print('War')


### FIXED CODE ###

n, m, x, y = map(int, input().split())
if x>y :
    print('War')
else  :
    X = sorted(list(map(int, input().split())))
    Y = sorted(list(map(int, input().split())))
    a = 0
    for i in range(x+1, y+1):
        if X[-1]<i and i <= Y[0] and x < i and i <= y:
            print('No War')
            break
        else :
            a += 1
    if a == y-x:
        print('War')