Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(int(input()))
if not 1 in l:
    two=1
else:
    two=0
if not 2 in l:
    if two==1:
        one=2
    else:
        one=1
lis=[two,one]
for _ in range(3,n+1):
    if not _ in l:
        lis.append((lis[_-3]+lis[_-2])%1000000007)
    else:
        lis.append(0)
print(lis[-1])

### FIXED CODE ###

import sys
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(int(input()))
if n==1:
    if 1 in l:
        print(0)
    else:
        print(1)
    sys.exit()
ans1=0
ans2=0
c=0
if 1 in l:
    c+=1
    if 2 in l:
        print(0)
        sys.exit()
    else:
        ans2=1
else:
    ans1=1
    if 2 in l:
        c+=1
    else:
        ans2=2
ans=[0,ans1,ans2]
S=2
while S<n:
    S+=1
    if c>=len(l):
        ans.append((ans[-1]+ans[-2])%1000000007)
    elif S==l[c]:
        c+=1
        ans.append(0)
    else:
        ans.append((ans[-1]+ans[-2])%1000000007)
print(ans[-1])
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

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

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

# 中央値を取るのがみそ


### FIXED CODE ###

# A - Multiple of 2 and N
# https://beta.atcoder.jp/contests/abc102/tasks/abc102_a

# A_Multiple_of_2_and_N.py

N = int(input())

if N == 1:
    print(2)
elif N%2 == 0:
    print(N)
else:
    print(N*2)
h,w=map(int,input().split())
s=[list(input()) for _ in range(w)]
for i in range(h):
    for j in range(w):
        if i==0:
            if j==0 and s[0][0]=='.':
                l1=[s[0][1],s[1][0],s[1][1]]
                l1l=l1.count('#')
                s[0][0]=l1l
            elif j==w-1 and s[0][w-1]=='.':
                r1=[s[0][w-2],s[1][w-2],s[1][w-1]]
                r1r=r1.count('#')
                s[0][w-1]=r1r
            elif j!=0 and j!=w-1 and s[0][j]=='.':
                l1j=[s[0][j-1],s[0][j+1],[s[1][j-1],s[1][j],s[1][j+1]]
                l1jj=l1j.count('#')
                s[0][j]==l1jj
            else:pass
        elif i==h-1:
            if j==0 and s[h-1][0]=='.':
                lh=[s[h-1][1],s[h-2][0],s[h-2][1]]
                lhl=lh.count('#')
                s[h-1][0]=lhl
            elif j==w-1 and s[h-1][w-1]=='.':
                rh=[s[h-1][w-2],s[h-2][w-2],s[h-2][w-1]]
                rhr=rh.count('#')
                s[h-1][w-1]=rhr
            elif j!=0 and j!=w-1 and s[h-1][j]=='.':
                lhj=[s[h-1][j-1],s[h-1][j+1],[s[h-2][j-1],s[h-2][j],s[h-2][j+1]]
                lhjj=lhj.count('#')
                s[0][j]==lhjj
            else:pass
        else:
            if j==0 and s[i][0]=='.':
                li=[s[i-1][0],s[i-1][1],s[i][1],s[i+1][1],s[i+1][0]]
                lil=li.count('#')
                s[i][0]=lil
            elif j==w-1 and s[i][w-1]=='.':
                ri=[s[i-1][w-1],s[i-1][w-2],s[i][w-1],s[i+1][w-2],s[i+1][w-1]]
                rir=ri.count('#')
                s[i][w-1]=rir
            elif j!=0 and j!=w-1 and s[i][j]=='.':
                lij=[s[i-1][j-1],s[i-1][j],s[i-1][j+1],s[i][j-1],s[i][j+1],s[i+1][j-1],s[i+1][j],s[i+1][j+1]]
                lijj=lij.count('#')
                s[i][j]==lijj
            else:pass
    print("".join(s[i]))

### FIXED CODE ###

h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
l=[]
l.append(['*']*(w+1))
for i in range(h):
    l1=s[i]
    l1.insert(0,'*')
    l1.append('*')
    l.append(l1)
l.append(['*']*(w+1))

for i in range(1,h+1):
    for j in range(1,w+1):
        c=0
        if l[i][j]=='.':
            c+=l[i-1][j-1:j+2].count('#')
            c+=l[i][j-1:j+2].count('#')
            c+=l[i+1][j-1:j+2].count('#')
            l[i].pop(j)
            l[i].insert(j,str(c))
            
for i in range(1,h+1):
    print(''.join(l[i][1:w+1]))
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(input()) for _ in[0]*N]
 for d in[int(input())for _ in[0]*M]:
  p+=d if N<p+d else d+S[p+d]
  if N<=p+1:break
  k+=1
 print(k)


### FIXED CODE ###

import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)
n,k = input().split(' ')
n = int(n)
k = int(k)
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
diffs = []
for i in range(n-k+1):
    diffs.append(h[i+k] - h[i])
print(min(diffs))


### FIXED CODE ###

n,k = input().split(' ')
n = int(n)
k = int(k)
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
diffs = []
for i in range(n-k+1):
    diffs.append(h[i+k-1] - h[i])
print(min(diffs))
n = int(input())
def get_h(pos,cx,cy,H):
  r= H - abs(pos[0]-cx) - abs(pos[1]-cy)

  return r

points = []
for i in range(n):
  x,y,h = map(int,input().split())
  if h == 0:
    continue
  points.append([x,y,h])
  
ans = []
q = []
if ans == []:
  for i in range(101):
    for j in range(101):
      d = get_h(points[0],i,j,0)- get_h(points[1],i,j,0)
      if points[0][2]- points[1][2] == d:
        ans.append([i,j])
        q.append([i,j])
for k in range(len(points)):
  for l in range(k+1,len(points)):
    for elem in q:
      i = elem[0]
      j = elem[1]
      if points[k][2] - points[l][2] != abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):
        if elem in ans:
          ans.remove(elem)
h = abs(points[0][0]-ans[0][0])+abs(points[0][1]-ans[0][1]) + points[0][2]
print('{} {} {}'.format(ans[0][0],ans[0][1],h))

### FIXED CODE ###

n = int(input())
hist = [tuple(map(int,input().split())) for _ in range(n)]
hist.sort(key=lambda x: x[2], reverse=1)

cands = []
x0,y0,h0 = hist[0]

for i in range(0,101):
  for j in range(0,101):
    if h0 == 0:
      cands.append((i,j,1))
    else:
      cands.append((i,j, h0+abs(i-x0)+abs(j-y0)))
    
for X,Y,H in cands:
  for x,y,h in hist:
    if max(H-abs(X-x)-abs(Y-y),0) == h:
      continue
    else:
      break
  else:
    print(X,Y,H)
    break
n = int(input())
s = input()
k = int(input())
for i in range(n):
  if a[k-1] == a[i]: print(a[i],end="")
  else: print("*",end="")

### FIXED CODE ###

#!/usr/bin/env python3
n = int(input())
a = input()
k = int(input())
for i in range(n):
    if a[k-1] == a[i]: print(a[i],end="")
    else: print("*",end="")
from sys import stdin
from math import factorial
 
if __name__ == '__main__':
 
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
 
    tmp = 1000000007
    r = 0
    for r in range(K)
        r += 1
        n = N - K + 1
 
        if n - r < 0 or K - r < 0:
            print(0)
            continue
 
        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))
 
        print((ret * ret2) % tmp)

### FIXED CODE ###

from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        if n - r < 0 or K - r < 0:
            print(0)
            continue

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)
#https://atcoder.jp/contests/abc128
# -*- coding: utf-8 -*-

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

k = []
s = []
for i in range(m):
    x = list(map(int,input().split()))
    k.append(x[0])
    y = []
    for j in range(x[0]):
        y.append(x[j+1])
    s.append(y)

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

cnt = 0
for i in range(1024):
    x = format(i,"08b")[::-1]
    if x[n] == "1":
        break

    for j in range(m):
        tmpSum = 0
        for k in s[j]:
            tmpSum += int(x[k-1])
        if tmpSum%2 is not p[j]:
            break
    else:
        cnt += 1

print(cnt)


    

### FIXED CODE ###

#https://atcoder.jp/contests/abc128
# -*- coding: utf-8 -*-

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

k = []
s = []
for i in range(m):
    x = list(map(int,input().split()))
    k.append(x[0])
    y = []
    for j in range(x[0]):
        y.append(x[j+1])
    s.append(y)

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

cnt = 0
for i in range(1024):
    x = format(i,"010b")[::-1]
    if n < 10 and x[n] == "1":
        break
    
    for j in range(m):
        tmpSum = 0
        for k in s[j]:
            tmpSum += int(x[k-1])
        if tmpSum%2 is not p[j]:
            break
    else:
        cnt += 1

print(cnt)
x = input().split()
num = Case
 
for i in range(1,10001):
    print("{} {} : {}".format(num,i,x))
    i += 1

### FIXED CODE ###

i = 1
while True:
     x = int(input())
     if x == 0: break
     print('Case {}: {}'.format(i, x))
     i += 1
a, b, c = map(int, raw_input().split())
2.if (b-a) = (c-b):
3.    print("YES")
4.else:
5.    print("NO")


### FIXED CODE ###

a, b, c = map(int, input().split())
if (b-a) == (c-b):
    print("YES")
else:
    print("NO")
from collections import defaultdict

n, m=map(int,input().split())
visited=[False for _ in range(n)]
graph = defaultdict(list)


def dfs(node):
    visited[node]=1
    for next_node in graph[node]:
        if visited[next_node]==0:
            dfs(next_node)

for _ in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    graph[a].append(b)
    graph[b].append(a)

ans = -1
for i in range(n):
    if not visited[i]:
        dfs(i)
        ans += 1
print(ans)

### FIXED CODE ###

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

from collections import defaultdict

n,m=map(int,input().split())
visited=[0]*n
d=defaultdict(list)
def dfs(n):
    visited[n]=1
    #print(visited)
    for i in d[n]:
        if visited[i]==0:
            dfs(i)

for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    d[a].append(b)
    d[b].append(a)

r=-1
for i in range (n):
    if visited[i]==0:
        dfs(i)
        r+=1
print(r)
a, h = map(int, input())
print((a+h-1)//h))


### FIXED CODE ###

a, h = map(int, input().split())
print((a+h-1)//h)
N = int(input())
a = list(map(int,input().split()))
Kisuu = 0
YonBaisuu = 0
NiBaisuu = 0

for j in range(N):

  if a[j]%2 == 1:
    Kisuu += 1
  elif a[j]%4 == 0:
    YonBaisuu += 1
  else :
    NiBaisuu +=1

  
if Kisuu <= YonBaisuu:
  print('Yes')
else :
  if NiBaisuu == 0:
    if YonBaisuu >= (Kisuu+1):
      print('Yes')
  else:
    print('No')




### FIXED CODE ###

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

print((n-1)*(m-1))
if a >= 3200:
  print(s)
else:
  print("red")

### FIXED CODE ###

a = int(input())
s = input()
if a>=3200:
  print(s)
else:
  print("red")
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right, bisect_left
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

# N以下の素数列挙(エラトステネスの篩)
def cal_primes(N):
    # 素数候補をリストでもつ
    candidate = [*range(2, N+1)]
    primes = []

    while candidate[0]**2 <= N:
        primes.append(candidate[0])
        candidate = [*filter(lambda x: x % candidate[0] != 0, candidate)]
    
    primes.extend(candidate)
    return primes

def main():
    N = int(input())
    primes = cal_primes(55555)
    ans = [2]
    
    for i in range(N-1):
        b = bisect_right(primes, ans[i]*2)
        ans.append(primes[b])
    print(*ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right, bisect_left
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

# N以下の素数列挙(エラトステネスの篩)
def cal_primes(N):
    # 素数候補をリストでもつ
    candidate = [*range(2, N+1)]
    primes = []

    while candidate[0]**2 <= N:
        primes.append(candidate[0])
        candidate = [*filter(lambda x: x % candidate[0] != 0, candidate)]
    
    primes.extend(candidate)
    return primes

def main():
    N = int(input())
    primes = cal_primes(55555)
    primes = [*filter(lambda x: x % 5 == 1, primes)]
    
    print(*primes[:N])


if __name__ == "__main__":
    main()
t=[0,1]
for i in range(2,90):
  t.append(t[i-1]+t[i-2])
print(t(int(input())

### FIXED CODE ###

t=[2,1]
for i in range(2,90):
  t.append(t[i-1]+t[i-2])
print(t[int(input())])
N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>=L[i] and N<=L[i+1]):
        print(L[i+1])
    else:
        continue


### FIXED CODE ###

N=int(input())
L=[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue
A, B = map(int, input().split())
cnt=0
for i in range(A, B+1) :
    str_i=str(i)
    rev_i=str_i[::-1]
    t=len(str_i)//2
    if len(str_i)%2==1 and str_i[:t+1] == rev_i[:t+1] :
        cnt=cnt+1
print(cnt)

### FIXED CODE ###

a=input()
b=input()
c=input()
print(a[0]+b[1]+c[2])
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

# AB = [[int(x) for x in input().split()] for _ in range(N-1)]

# print(AB)

# 添字を1からにしたいのでN+1
graph = [[] for _ in range(N+1)]

# 各頂点に隣接する頂点
for _ in range(N-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

# print(graph)
counter = [0] * (N+1)

# print(counter)

# PX = [[int(x) for x in input().split()] for _ in range(Q)]

# 各頂点に点数を足す
for _ in range(Q):
  p, x = map(int, input().split())
  counter[p] += x


def shori(pa,c,val):
  val += counter[c]
  counter[c] = val
  for i in graph[c]:
    if i == pa:
      continue
    shori(c,i,val)
  
shori(0,1,0)
  

print(" ".join(map(str, counter[1:])))




### FIXED CODE ###

a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print('red')
import math

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

cd_gcd = math.gcd(c, d)
cd_lcm = c * d // cd_gcd

ans = (b - a) - (b - a)//c - (b - a)//d + (b - a)//cd_lcm
print(ans)

### FIXED CODE ###

# import math
from fractions import gcd

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

cd_lcm = c * d // gcd(c, d)

x1 = b//c - (a-1)//c
x2 = b//d - (a-1)//d
x3 = b//cd_lcm - (a-1)//cd_lcm

print((b-(a-1))-x1-x2+x3)
n = int(input())
a = [int (i) for i in input().split()]
ans=[]
b =0
for i in range(1,n):
	for j in range(i+1,n):
		if a[j-1]>=a[j]:
			b+=1
	ans.append(b)
	b=0

print(max(ans))

### FIXED CODE ###

n = int(input())
h = [int (i) for i in input().split()]
ans=0

l=[]

if n==1:
	l.append(ans)

else:
	for i in range(1,n):
		if h[i-1] >= h[i]:

			ans+=1

			if i==n-1:
				l.append(ans)

		else:

			l.append(ans)

			ans=0

print(max(l))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
                x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def nums(self,x):
        return abs(self.parents[self.find(x)])

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(M):
    A[i],B[i] = map(int, input().split())
ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if j!=i:
            uf.union(A[j]-1,B[j]-1)
    if len(uf.roots())>1:
        ans += 1
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
edges = [(0,0) for _ in range(M)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    edges[i] = (a-1,b-1)

import sys
sys.setrecursionlimit(10**8)

def dfs(v, es):
    #print(h,w)
    if len(es[v])==0:
        return 0
    for u in es[v]:
        if visited[u]==False:
            visited[u]=True
            dfs(u,es)
    return 0

import copy
ans = 0
for i in range(M):
    visited = [False]*N
    a,b = edges[i]
    es = copy.deepcopy(edge)
    # print(edge,a,b)
    es[a].remove(b)
    es[b].remove(a)
    for v in range(N):
        if visited[v]==False:
            visited[v]=True
            dfs(v,es)
            if False in visited:
                # print(a,b)
                break
    else:
        continue
    ans += 1
print(ans)
N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit(1)

for h in range(0,len(words),2):
    print(h)
    if words[h] == words[h+1]:
        words[h] = True
        words[h+1] = True
    else:
        print("No")
        exit(1)
    
if all(l):
    print("Yes")


### FIXED CODE ###

N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit()

for h in range(0,len(words),2):
    if words[h] != words[h+1]:
        print("No")
        exit()
print("Yes")
X,A,B = map(int,input()split())

print('delicious' if B <= A else 'safe' if B <= A+X else 'dangerous')

### FIXED CODE ###

X,A,B = map(int,input().split())

print('delicious' if B <= A else 'safe' if B <= A+X else 'dangerous')
N = int(input())
A = list(map(int,input().split()))

A = sorted(A,reverse=True)

if N <= 3:
  print(sum(A[:-1]))
elif N % 2 == 0:
  ans = A[0] + sum(A[1:N//2])*2
elif N % 2 == 1:
  ans = A[0] + sum(A[1:N//2])*2 + A[1+N//2]
  
print(ans)

### FIXED CODE ###

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

ans = A[0]

for i in range(1,(N-2)//2+1):
  ans += A[i]*2
  
if N % 2 == 1:
  ans += A[(N-2)//2 + 1]

print(ans)
while True:
  h, w = map(int, raw_input().split())
  if (h == 0 and w == 0):
    break
  for i in range(0,h):
    for j in range(0,w):
      if i==0 or j==0 or i==h-1 or j==w-1:
??????    print ("#")
      else: 
        print (".")
    print("\n)
  

### FIXED CODE ###

while True:
  h, w = map(int, raw_input().split())
  if (h == 0 and w == 0):
    break
  for i in range(0,h):
    if i == 0 or i == h-1:
      print ('#' * w)
    else: 
      print ('#' + '.' * (w - 2) + '#' )
  print
#coding: UTF-8
import math

A, B, DEGREE = list(map(int, input().split()))
RADIAN = math.radians(DEGREE)

C = sqrt(pow(A, 2)*pow(B, 2) - 2*A*B*math.cos(RADIAN))
S = A*B*math.sin(RADIAN)/2
H = A*math.sin(RADIAN)

print("%.10f %.10f %.10f"%(S, A+B+C, h))


### FIXED CODE ###

#coding: UTF-8
import math

A, B, DEGREE = list(map(int, input().split()))
RADIAN = math.radians(DEGREE)

C = math.sqrt(A*A+B*B-2*A*B*math.cos(RADIAN))
S =A*B*math.sin(RADIAN)/2.0
H = 2*S/A

print("%.10f %.10f %.10f"%(S, A+B+C, H))
N,X = map(int,input().split())
L = list(map(int,input().split()))
D,i,cnt = 0,0,1 
while(D <= X):
  D = D + L[i]
  cnt +=1
  i += 1
print(cnt)

### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))
L.append(0)
D,i,cnt = 0,0,0
while(D <= X and cnt <= N):
  D = D + L[i]
  cnt +=1
  i += 1
print(cnt)
X, N = map(int, input().split())
p = list(map(int, input().split()))

for d in range(X + 1):
    if X - d not in p:
        print(X-d)
        exit()
    elif X + d not in p:
        print(X+d)
        exit()


### FIXED CODE ###

import numpy as np
x = list(map(int, input().split()))

sub=[]
for i in range(len(x)):
    if x[i]== 0:
        sub.append(i+1)
print(*sub)
s = input()
gx, gy = map(int, input().split())
n = len(s)
X, Y = [], []
x, y, flag = 0, 0, 0
for i in range(n):
    if s[i] == 'F' and flag == 0:
        x += 1
    elif s[i] == 'F' and flag == 1:
        y += 1
    else:
        if flag and y > 0:
            Y.append(y)
            y = 0
        elif not flag and x > 0:
            X.append(x)
            x = 0
        flag = (flag + 1) % 2
if flag and y > 0:
    Y.append(y)
elif not flag and x > 0:
    X.append(x)
MAX_X, MAX_Y, l_X, l_Y = sum(X), sum(Y), len(X), len(Y)
if MAX_X < gx or MAX_Y < gy:
    print("No")
else:
    dp_x = [[False for _ in range(MAX_X * 2 + 1)] for _ in range(l_X + 1)]
    dp_y = [[False for _ in range(MAX_Y * 2 + 1)] for _ in range(l_Y + 1)]
    dp_x[0][MAX_X], dp_y[0][MAX_Y] = True, True
    for i in range(l_X):
        for x in range(MAX_X * 2 + 1):
            if x + X[i] < MAX_X * 2 + 1:
                dp_x[i + 1][x] |= dp_x[i][x + X[i]]
            if x - X[i] >= 0:
                dp_x[i + 1][x] |= dp_x[i][x - X[i]]
    for i in range(l_Y):
        for y in range(MAX_Y * 2 + 1):
            if y + Y[i] < MAX_Y * 2 + 1:
                dp_y[i + 1][y] |= dp_y[i][y + Y[i]]
            if x - X[i] >= 0:
                dp_y[i + 1][y] |= dp_y[i][y - Y[i]]
    if dp_x[l_X][gx + MAX_X] and dp_y[l_Y][gy + MAX_Y]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

S = input() + 'E'
gx, gy = map(int, input().split())
X, Y = [], []
x, y, i, flag = 0, 0, 0, 1
while i <= len(S):
    f = 0
    while S[i] == 'F':
        f += 1
        i += 1
    if flag:
        X.append(f)
    else:
        Y.append(f)
    flag = (flag + 1) % 2
    if S[i] == 'E':
        break
    i += 1
gx -= X[0]
for x in sorted(X[1:], reverse = True):
    if gx > 0:
        gx -= x
    else:
        gx += x
for y in sorted(Y, reverse = True):
    if gy > 0:
        gy -= y
    else:
        gy += y
if gx == gy == 0:
    print("Yes")
else:
    print("No")
N = int(input())

result = 0
if(0<N<=pow(10,5))
    if len(str(N)) % 2 == 0:
        loop = ((len(str(N)) - 1) -1) //2 + 1
        for i in range(loop):
            result += 9 * pow(10,2*i)
    else:
        for i in range(len(str(N)) - 2):
            result += 9 * pow(10,i)
        result += N - pow(10,len(str(N)) - 1) + 1

print(result)

### FIXED CODE ###

N = int(input())

print(sum(len(str(i)) % 2 for i in range(1,N+1)))
string = input()

z_idx = len(string) - string[::-1].index('Z') - 1

a_idx = string.index('A')

print (z_idx - a_idx + 1)

### FIXED CODE ###

x = int(input())

print ('ABC' if x < 1200 else 'ARC')
n, x, t = map(int, input().split(" "))

out = int(math.ceil(n/x)) * t
print(out)

### FIXED CODE ###

import math
n, x, t = map(int, input().split(" "))

out = int(math.ceil(n/x)) * t if x != 0 else 0
print(out)
def main():
  n,k = map(int,input().split())
  a = list(map(int,input().split()))
  l = [1]

  for i in range(1,k+1):
    ind = l[-1]
    if a[ind-1] in set(l):
      l.append(a[ind-1])
      roop = l[-1]
      nokori = k-i
      break
    
    else:
      l.append(a[ind-1])
    
  l.pop()
  rooplist = l[l.index(roop):]
  rooplen = len(rooplist)
  mod = nokori%rooplen

  print(rooplist[mod])


if __name__ == '__main__':
    main()

### FIXED CODE ###

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

d = {}
for i in range(1, n + 1):
    d[i] = a[i - 1]

did = set()
route = [1]

now = 1
for i in range(k):
    now = d[now]
    route.append(now)
    if now in did:
        break
    did.add(now)

if k < 10 ** 6:
    now = 1
    for i in range(k):
        now = d[now]

    print(now)

else:
    for i in range(len(route)):
        if route[i] == route[-1]:
            roop = route[i:-1]
            print(roop[(k - i) % len(roop)])
            exit()