Harryxun/stf_run huggingface dataset:
A=(imput())
B=(imput())
if A<=8 and B<=8:
  print('Yay!')
else:
  print(':(')


### FIXED CODE ###

A,B=map(int,input().split())
if A<=8 and B<=8:
  print('Yay!')
else:
  print(':(')
import sys
sys.setrecursionlimit(10**10)
t=input()
tl=list(t)
tln=len(t)
x=t.find("?")
while x != -1:
    if x == tln:
        tl[x]="D"
        break
    if tl[x+1]=="D":
        tl[x]="P"
    elif tl[x+1]=="?":
        tl[x]="P"
    else:
        tl[x]="D"
    t="".join(tl)
    x=t.find("?")
print(t)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
t=input()
tl=list(t)
tln=len(t)
x=0
for x in range(tln):
    if tl[x] == "?":
        if x == tln-1:
            tl[x]="D"
            break
        elif x==0:
            if tl[x+1]=="?":
                tl[x]="P"
                tl[x+1]="D"
            else:
                tl[x]="D"
        elif tl[x-1]=="P":
            tl[x]="D"
        elif tl[x+1]=="?":
            tl[x]="P"
            tl[x+1]="D"
        elif tl[x+1]=="D":
            tl[x]="P"
        else:
            tl[x]="D"
t="".join(tl)
print(t)
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans


N=int(input())

PN=PrimeNumber(N)
c=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if j>i:
            break
        while temp>=j:
            if temp%j==0:
                c[j]+=1
                temp=temp//j
            else:
                break

ans=1
for i in PN:
    ans*=(c[i]+1)
ans=ans%(10**9+7)
print(ans)

### FIXED CODE ###

def PrimeNumber(N):
    if N==2:
        ans=[2]
        return ans
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans

N=int(input())

if N==1:
    print(1)
    exit()

mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if temp<j:
            break
        cnt=0
        while temp%j==0:
            cnt+=1
            temp=temp//j
        P[j]+=cnt

ans=1

for i in range(1,N+1):
    if P[i]!=0:
        ans=(ans*(P[i]+1))%mod
print(ans)
N = int(input())
x = [int(i) for i in input()]
print(len(x) + (N // min(x)))

### FIXED CODE ###

N, *x = map(int, open(0))
print(4 - (-N // min(x)))
import numpy as np
n,d=map(int,input().split())
x=[]
for i in range(n):
  l=map(int,input().split())
  x.append(l)

x=np.array(x)

def dist(x,y):
  diff=x-y
  diff_sq=np.square(diff)
  return(np.sqrt(np.sum(diff_sq)))

ans=0
for N in range(n):
    for i in range(N,n):
        X = dist(x[N], x[i])
 
        if X.is_integer():
            ans += 1
 
print(ans)


### FIXED CODE ###

import numpy as np
def is_square(n):
    for i in range(200):
        if i*i == n:
            return True
    return False
n,d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int,input().split())))

x = np.array(x)

count = 0
for i in range(n):
    for j in range(i+1,n):
        l = x[i] - x[j]
        l = np.square(l)
        l = np.sum(l)
        flag = is_square(l)
        if(flag) :
            count +=1

print(count)
a=int(input())
Paper=list(map(int,input().split()))
m=0
for i in range (a):
  if Paper[i]%2==0:
    if not Paper[i]%3==0 or Paper[i]%5==0:
      m=m+1
return m

if not m=0:
  print("DENIED")
else:
  print("APPROVED")


### FIXED CODE ###

a=int(input())
Papers=list(map(int,input().split()))
m=0
for i in range (a):
  if Papers[i] %2==0:
    if not (Papers[i] %3==0 or Papers[i] %5==0):
      m=m+1

if not m==0:
  print("DENIED")
else:
  print("APPROVED")
import numpy as np
N, W = map(int, input().split())

items = [tuple(map(int, input().split())) for _ in range(N)]

dp = np.zeros(W+1)

for i, (w, v) in enumerate(items):
    tmp = np.zeros(W+1)
    tmp[w:] = dp[:W-w+1] + v
    dp[w:] = np.fmax(tmp[w:], dp[w:])

print(int(dp[-1]))


### FIXED CODE ###

import numpy as np
N, W = map(int, input().split())

items = [tuple(map(int, input().split())) for _ in range(N)]

dp = np.full(N*1000 +1, W+1) #横軸を価値の値に変換する
dp[0] = 0

for i, (w, v) in enumerate(items):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)

print(np.max(np.where(dp <= W)))
S = int(input())

h = S//3600
m = (S//60)-(S//3600)
s = S//60

print(h,:,m,:,s)



### FIXED CODE ###

S = int(input())
h = S//3600
m = (S//60)-60*(S//3600)
s = S%60
print('{}:{}:{}'.format(h,m,s))
# -*- coding: utf-8 -*-
"""
Created on Thu Oct  3 07:43:37 2019

@author: avina
"""

import heapq

class Maxheap():
    
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)
    
    def push(self, value):
        heapq.heappush(self.heap, -value)
    
    def pop(self):
        return -heapq.heappop(self.heap)

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

l = list(map(int, input().split()))
a = Maxheap(l)
for i in range(l):
    b = a.pop()//2
    a.push(b)
    
sums = 0
for i in range(n):
    sums += a.pop()
print(sums)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Oct  2 07:56:16 2019

@author: avina
"""
from queue import PriorityQueue as Q
n,t = map(int,input().split())

q = Q()
for i in input().split():
    a = -1*int(i)
    q.put(a)

while t >0:
    a = -1*(q.get())
    a = -1*(a//2)
    q.put(a)
    t-=1

ans = 0
while q.qsize()>0:
    ans += q.get()
print(-1*ans)
n, k, s = map(int,input().split())
anslist = [0] * n
for i in range(k):
    anslist[i] = s
for i in range(len(anslist)):
    print(s[i])

### FIXED CODE ###

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

if s != int(1e9):
    anslist = [int(1e9)] * n
    for i in range(k):
        anslist[i] = s
    for i in range(len(anslist)):
        print(anslist[i])
else:
    anslist = [1] * n
    for i in range(k):
        anslist[i] = s
    for i in range(len(anslist)):
        print(anslist[i])
N = input()
if N<1000:
    print("ABC")
else:
    print("ABD")  


### FIXED CODE ###

N = int(input())
if N<1000:
    print("ABC")
else:
    print("ABD")
from sys import stdin
import math
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = math.gcd(c, d)
koubai = c * d // kouyaku
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print(b_s - a_s)

### FIXED CODE ###

from sys import stdin
import fractions
a,b,c,d = [int(x) for x in stdin.readline().rstrip().split()]
kouyaku = fractions.gcd(c, d)
koubai = c * d // fractions.gcd(c, d)
b_s = b - b//c - b//d + b//koubai
a_s = a-1 - (a-1)//c - (a-1)//d + (a-1)//koubai
print(b_s - a_s)
import sys

[a, b, c] = [int(x) for x in sys.stdin.readline()]

counter = 0
for value in range(a, b + 1):
    if c / value == 0:
        counter += 1

print(counter)

### FIXED CODE ###

import sys

[a, b, c] = [int(x) for x in sys.stdin.readline().split()]
counter = 0
for value in range(a, b + 1):
    if c % value == 0:
        counter += 1

print(counter)
def find(tab, a):
    if tab[0][a]==-1:
        return a
    tab[0][a] = find(tab, tab[0][a])
    return tab[0][a]

def size(tab, a):
    return tab[1][a]

def union(tab, a, b):
    p1, p2 = find(tab, a), find(tab, b)
    if p1 != p2:
        tab[0][p1] = p2
        tab[1][p2] += tab[1][p1]

N, M = [int(a) for a in input().split(" ")]
ABs = [[int(a) for a in input().split(" ")] for i in range(M)]
tab = [[-1]*N, [1]*N]
arr = []

for a, b in reversed(ABs):
    pa, pb = (find(tab, a-1), find(tab, b-1))
    na, nb = (size(tab, pa), size(tab, pb))
    if pa!=pb:
        dn = ((na+nb)*(na+nb-1)//2)-(na*(na-1)//2)-(nb*(nb-1)//2)
        arr.append(dn)
        union(tab, a-1, b-1)
    else:
        arr.append(0)

acc = 0
for cp in reversed(arr):
    acc += cp
    print(acc)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def find(tab, a):
    if tab[0][a]==a:
        return a
    tab[0][a] = find(tab, tab[0][a])
    return tab[0][a]

def union(tab, a, b):
    p1, p2 = (find(tab, a), find(tab, b))
    if p1 != p2:
        tab[0][p1] = p2
        tab[1][p2] += tab[1][p1]

def size(tab, a):
    return tab[1][a]

N, M = [int(a) for a in input().split(" ")]
ABs = [[int(a) for a in input().split(" ")] for i in range(M)]
tab = [[i for i in range(N)], [1 for i in range(N)]]
arr = []

for a, b in reversed(ABs):
        a, b = (a-1, b-1)
        pa, pb = (find(tab, a), find(tab, b))
        na, nb = (size(tab, pa), size(tab, pb))
        if pa!=pb:
            dn = ((na+nb)*(na+nb-1)//2)-(na*(na-1)//2)-(nb*(nb-1)//2)
            arr.append(dn)
            union(tab, a, b)
        else:
            arr.append(0)

acc = 0
for cp in reversed(arr):
    acc += cp
    print(acc)
from scipy.sparse.csgraph import dijkstra

n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
edge=[]
for i in range(n):
  for j in range(n):
    if i>=j:
      continue
    edge.append((arr[i][j],(i,j)))
edge=sorted(edge,key=lambda x:x[0])
g=[[float('inf')]*n for _ in range(n)]
ans=0
for i in range(n-1):
  w,(a,b)=edge[i]
  g[a][b]=w
  g[b][a]=w
  ans+=w
for i in range(n-1,(n*(n-1))//2):
  w,(a,b)=edge[i]
  cost=int(dijkstra(g,indices=a)[b])
  if w==cost:
    continue
  elif w<cost:
    g[a][b]=w
    g[b][a]=w
    ans+=w
  elif w>cost:
    print(-1)
    break
else:
  print(ans)

### FIXED CODE ###

def Warshall_Floyd(edges,N):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])
  return edges

n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
edge=[]
for i in range(n):
  for j in range(n):
    if i>=j:
      continue
    edge.append((arr[i][j],(i,j)))
edge=sorted(edge,key=lambda x:x[0])
g=[[float('inf')]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    g[i][j]=arr[i][j]
d=Warshall_Floyd(g,n)
ans=0
for w,(a,b) in edge:
  if d[a][b]<w:
    print(-1)
    break
  else:
    tmp=10**10
    for k in range(n):
      if k==a or k==b:
        continue
      tmp=min(tmp,d[a][k]+d[k][b])
    if w==tmp:
      continue
    else:
      ans+=w
else:
  print(ans)
import numpy as np
N = input()
s = np.array(map(int, input().split()))
count = 0
while True:
  if np.all( (s%2) == 0):
    count += 1
    s = s
  else:
    break
print(count)


### FIXED CODE ###

import numpy as np
N = input()
s = np.array(list(map(int, input().split())))
count = 0
while True:
  _exp = 2**(count+1)
  if np.all( s%_exp == 0):
    count += 1
  else:
    break
print(count)
from scipy.special import import comb

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

ans = comb(n,2,exact=True) + comb(m,2,exact=True)


### FIXED CODE ###

from math import factorial
n,m = map(int,input().split())

if n == 0:
   N = 0
elif n == 1:
    N = 0
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
elif m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))
N=input()

lists = []
temp=[i for i in range(10)]

dic={0:1}

for i in N:
    new_dic={}
    if i == "?":
        for amari,count in list(dic.items()):
            amari*=10
            for num in temp:
                a = (amari + num) % 13
                if a in new_dic:
                    new_dic[a]+=count
                else:
                    new_dic[a]=count
    else:
        for amari,count in list(dic.items()):
            a = (amari*10 + num)%13
            if a in new_dic:
                new_dic[a]+=count
            else:
                new_dic[a]=count
    dic = new_dic

try:
    print(dic[5]%(10**9 + 7))
except:
    print(0)

### FIXED CODE ###


N=input()

lists = []
temp=[i for i in range(10)]

MOD=10**9+7

dic={0:1}

for i in N:
    new_dic={}
    hoge=list(dic.items())
    if i == "?":
        for amari,count in hoge:
            amari*=10
            for num in temp:
                a = (amari + num) % 13
                if a in new_dic:
                    new_dic[a]+=count
                else:
                    new_dic[a]=count
    else:
        num=int(i)
        for amari,count in hoge:
            a = (amari*10 + num)%13
            if a in new_dic:
                new_dic[a]+=count
            else:
                new_dic[a]=count
    for key in new_dic:
        new_dic[key] %= MOD
    dic = new_dic

try:
    print(dic[5])
except:
    print(0)
def main()
    x, y =[int(i) for i in input().split()]

    while y != 0 :
        x, y = y, x%y
    print(x)
    
    if __name__ == '__main__':
        def main()

### FIXED CODE ###

def main() :
    x, y = [int(i) for i in input().split()]
    while y != 0 :
        x, y = y, x%y

    print(x)

if __name__ == '__main__':
    main()
n = int(input()) #長さ
s = str(input()) #文字列
cnt = 0 #暗証番号数
 
for a in range(10): #1文字目
  for b in range(10): #2文字目
    for c in range(10): #3文字目
      flg = False
      for i in range(n-2):
        if str(a) == s[i]:
          tmp_i = i + 1
          for j in range(tmp_i,n-1):
            if str(b) == s[j]:
              tmp_i = j + 1
              for k in range(tmp_i,n):
                if str(c) == s[k]:
                  cnt = cnt + 1
                  flg = True
                  break
              else:
                flg = True
            if flg:
              break
          else:
            flg = True
      	if flg:
          break
print(cnt)

### FIXED CODE ###

n = int(input()) #長さ
s = str(input()) #文字列
cnt = 0 #暗証番号数

for a in range(10): #1文字目
  for b in range(10): #2文字目
    for c in range(10): #3文字目
      flg = False
      check_a = s.find(str(a))
      if check_a != -1:
        tmp_s = s[check_a + 1:]
        check_b = tmp_s.find(str(b))
        if check_b != -1:
          tmp_t = tmp_s[check_b + 1:]
          check_c = tmp_t.find(str(c))
          if check_c != -1:
            cnt = cnt + 1            
print(cnt)
n = int(input())
str_s, str_t = input.split
new = ''
for i in range(0, n)
	new += str_s[i]
  	new += str_t[i]
print (new)

### FIXED CODE ###

n = int(input())
s,t = input().split()
new = ''
for i in range(n):
  new += s[i]
  new += t[i]
print (new)
A = str(input(''))
if A = 'a':
  print('b')
elif A = 'b':
  print('c')
elif A = 'c':
  print('d')
elif A = 'd':
  print('e')
elif A = 'e':
  print('f')
elif A = 'f':
  print('g')
elif A = 'g':
  print('h')
elif A = 'h':
  print('i')
elif A = 'i':
  print('j')
elif A = 'j':
  print('k')
elif A = 'k':
  print('l')
elif A = 'l':
  print('m')
elif A = 'm':
  print('n')
elif A = 'n':
  print('o')
elif A = 'o':
  print('p')
elif A = 'p':
  print('q')
elif A = 'q':
  print('r')
elif A = 'r':
  print('s')
elif A = 's':
  print('t')
elif A = 't':
  print('u')
elif A = 'u':
  print('v')
elif A = 'v':
  print('w')
elif A = 'w':
  print('x')
elif A = 'x':
  print('y')
else:
  print('z')



### FIXED CODE ###

A = str(input(''))
if A == 'a':
  print('b')
elif A == 'b':
  print('c')
elif A == 'c':
  print('d')
elif A == 'd':
  print('e')
elif A == 'e':
  print('f')
elif A == 'f':
  print('g')
elif A == 'g':
  print('h')
elif A == 'h':
  print('i')
elif A == 'i':
  print('j')
elif A == 'j':
  print('k')
elif A == 'k':
  print('l')
elif A == 'l':
  print('m')
elif A == 'm':
  print('n')
elif A == 'n':
  print('o')
elif A == 'o':
  print('p')
elif A == 'p':
  print('q')
elif A == 'q':
  print('r')
elif A == 'r':
  print('s')
elif A == 's':
  print('t')
elif A == 't':
  print('u')
elif A == 'u':
  print('v')
elif A == 'v':
  print('w')
elif A == 'w':
  print('x')
elif A == 'x':
  print('y')
else:
  print('z')
n = int(input())
xlist = []
for i in range(n):
    command = list(map(str,input().split()))
    if (command[0] == 'insert'):
        x = command[1]
        if (len(xlist) == 0):
            xlist.append(int(x))
        else:
            xlist.append(int(x))
            for i in range(1,len(xlist)):
                k = len(xlist) - i 
                j = k-1
                xlist[j], xlist[k] = xlist[k], xlist[j]
    elif (command[0] == 'delete'):
        x = command[1]
        if int(x) in xlist :
            xlist.remove(int(x))
    elif (command[0] == 'deleteFirst'):
        if (len(xlist) > 0):
            del xlist[0]
    elif (command[0] == 'deleteLast'):
        if (len(xlist) > 0):
            del xlist[-1]
nx = len(xlist)
for i in range(n):
    if ( i == n-1):
        print('{}'.format(xlist[i]), end = '')
    else:
        print('{}'.format(xlist[i]), end = ' ')


### FIXED CODE ###

from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))
import sys

n,k = [ int(i) for i in input().split(" ")]
arr = [ int(i) for i in input().split(" ")]



# 10 40
# 5 4 3 2 -1 0 0 0 0 0

# 30 413
# -170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0

negatives = []
zeros = []
positives = []
tmp = []

for i in arr:
  if i < 0:
    negatives.append(i)
  elif i == 0:
    zeros.append(i)
  else:
    positives.append(i)

negatives.sort()
zeros.sort()
positives.sort()

ngs = len(negatives) * len(positives)
if k < ngs:
  for i in range(len(negatives)):
    for j in range(i+1, len(negatives)):
      tmp.append(arr[i] * arr[j])
      if len(tmp) > k: break

  print(tmp[k-1])
  sys.exit()

k = k - ngs

zs = 0
for i in range(len(zeros)):
  zs += len(arr) - i-1

if k < zs:
  print(str(0))
  sys.exit()

k = k - zs

# positives.extend(negatives)
for i in range(len(positives)):
  for j in range(i+1, len(positives)):
    tmp.append(arr[i] * arr[j])

import pdb; pdb.set_trace()
tmp.sort()
print(tmp[k-1])

### FIXED CODE ###

from bisect import bisect_left, bisect_right
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
neg_end = bisect_left(A, 0)
pos_start = bisect_right(A, 0)

pos_cnt = N - pos_start
neg_cnt = neg_end
zero_cnt = N - (pos_cnt + neg_cnt)

neg_pairs_cnt = pos_cnt * neg_cnt
zero_pairs_cnt = zero_cnt * (pos_cnt + neg_cnt) + (zero_cnt * (zero_cnt-1) // 2)

if K <= neg_pairs_cnt:
  # X以下のpairはK個以上あるか？
  ok, ng = 0, -10**18
  while abs(ok - ng) > 1:
    X = (ok+ng) // 2
    or_higher_cnt, r = 0, pos_start
    # それぞれのnegごとに尺取り法
    for l in range(neg_end):
      while r < N and A[l] * A[r] > X:
        r += 1
      # positive_integers - (max_point - positive_start_index)
      or_higher_cnt += pos_cnt - (r - pos_start)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X
  print(ok)

elif K <= neg_pairs_cnt + zero_pairs_cnt:
  print(0)

else:
  K -= (neg_pairs_cnt + zero_pairs_cnt)
  ok, ng = 10**18, 0
  while abs(ok - ng)> 1:
    X = (ok+ng) // 2
    or_higher_cnt = 0

    r = N - 1
    for l in range(pos_start, N):
      while r < N and A[l] * A[r] > X and l < r:
        r -= 1
      or_higher_cnt += max(0, r-l)

    l = 0
    for r in range(neg_end-1, -1, -1):
      while l < N and A[l] * A[r] > X and l < r:
        l += 1
      or_higher_cnt += max(0, r-l)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X

  print(ok)
x = int(input())
s =  x * 360 / math.gcd(x, 360)
print(s/x)

### FIXED CODE ###

import math
x = int(input())
s =  x * 360 / math.gcd(x, 360)
print(int(s//x))
#input_f = "3 4 5\n2 1 2\n6 3 4\n1 1 1\n1 2 3"
def t_check(a,b,c):
    if a + b > c:
        if b + c > a:
            if a + c > b: return True
    return False



def f_check(a_, b_, c_):
    tmp = []
    tmp.append(a_)
    tmp.append(b_)
    tmp.append(c_)
    sqrts = []
    for i in range(3):
        sqrts.append(tmp[i]**2)
    m = max(sqrts)
    s = sum(sqrts)

    if m == (s - m): return(0)
    if m > (s - m): return(2)
    if m < (s - m): return(1)
    
    
counter=[0,0,0]
    
    
while(1):
    input_f = input()


    t = input_f.split("\n")[i].split()
    fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
    if t_check(fn,sn,tn):
        counter[f_check(fn,sn,tn)] += 1
    else: break
    

print(sum(counter),counter[0], counter[1], counter[2])

        



### FIXED CODE ###

def t_check(a,b,c):
    if a + b > c:
        if b + c > a:
            if a + c > b: return True
    return False

def f_check(a_, b_, c_):
    tmp = []
    tmp.append(a_)
    tmp.append(b_)
    tmp.append(c_)
    sqrts = []
    for i in range(3):
        sqrts.append(tmp[i]**2)
    m = max(sqrts)
    s = sum(sqrts)

    if m == (s - m): return(0)
    if m > (s - m): return(2)
    if m < (s - m): return(1)
    
counter=[0,0,0]
    
while(1):
    input_f = input()

    t = input_f.split()
    fn, sn, tn = int(t[0]),int(t[1]),int(t[2])
    if t_check(fn,sn,tn):
        counter[f_check(fn,sn,tn)] += 1
    else: break
    
print(sum(counter),counter[0], counter[1], counter[2])
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

n,m = map(int, input().split())
s = input()
t = input()
f=math.gcd(n,m)           #最大公約数
f2=n*m//f                          #最小公倍数


x = f2//n
y = f2//m

z = ['' for i in range(f2)]
for i in range(n):
    z[i*x] = s[i]
for i in range(m):
    if z[i*y] != '' and z[i*y] != t[i]:
        print(-1)
        sys.exit()
print(f2)

### FIXED CODE ###

# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

n,m = map(int, input().split())
s = input()
t = input()
f=fractions.gcd(n,m)           #最大公約数
f2=n*m//f                          #最小公倍数


x = f2//n
y = f2//m

for i in range(n):
    if (x*i)%y==0:
        if s[i] != t[x*i//y]:
            print(-1)
            sys.exit()
print(f2)
n,m = map(int, input().split())
div = 1000000007
ok [True] * n + 1
for _ in range(m):
  a = int(input())
  ok[a] = False
dp = [0] * (n + 1)
dp[0] = 1
if ok[1]:
  dp[1] = 1
else:
  dp[1] = 0

for i in range(2, n+1):
  if ok[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= div

print(dp[n])
  

### FIXED CODE ###

n,m = map(int, input().split())
div = 1000000007
ok = [True] * (n + 1)
for _ in range(m):
  a = int(input())
  ok[a] = False
dp = [0] * (n + 1)
dp[0] = 1
if ok[1]:
  dp[1] = 1
else:
  dp[1] = 0

for i in range(2, n+1):
  if ok[i]:
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= div

print(dp[n])
#C
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    if x==1 or x==0:
        return 1
    else:
        return (f(x-1)+f(x-2))%mod
s=f(a[0]-1)
for i in range(1,m):
    if a[i]-a[i-1]==1:
        print(0)
        break
    s=(s*f(a[i]-a[i-1]-2))%mod
else:
    s=(s*f(n-a[m-1]-1))%mod
    print(s)

### FIXED CODE ###

#C
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    b=1
    c=1
    if x==1 or x==0:
        return 1
    else:
        for i in range(x-1):
            b,c=(b+c)%mod,b
        return b
if m>=1:
    s=f(a[0]-1)
    for i in range(1,m):
        if a[i]-a[i-1]==1:
            print(0)
            break
        s=(s*f(a[i]-a[i-1]-2))%mod
    else:
        s=(s*f(n-a[m-1]-1))%mod
        print(s)
else:
    print(f(n))
# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	
	btnList = []
	for _ in range(N):
		tmp = int(input())
		btnList.append(tmp)
	
	tugi = btnList[0]
	i = 1
	if tugi-1 == 1:
	print(i)
	sys.exit()
	while i < N+1:
		i += 1
		tugi = btnList[tugi-1]
		if tugi-1 == 1:
			print(i)
			sys.exit()
	print(-1)
	
if __name__ == "__main__":
	main()
	

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	ai = [int(input()) for i in range(N)]
	
	now = 1
	count = 0
	for i in range(N):
		count = count + 1
		now = ai[now-1]
		if now == 2:
			print(count)
			exit()
	print(-1)
	
if __name__ == "__main__":
	main()