Harryxun/stf_run huggingface dataset:
N=int(input())
lamps=[]
for a in range(N):
    _=int(input())
    lamps.append(_)
lamps.insert(0,"aaa")

PressedButtons=[False]*N

a=1
count=0

if lamps.count(2)==0:
    print("-1")

while PressedButtons[a]==False :
    PressedButtons[a]=True
    count+=1
    a=lamps[a]
    if a==2:
        print(count)
        exit()
print('-1')


### FIXED CODE ###

N=int(input())
lamps=[]
for a in range(N):
    _=int(input())
    lamps.append(_)
lamps.insert(0,"aaa")

PressedButtons=[False]*int(N+1)

a=1
count=0

if lamps.count(2)==0:
    print("-1")
    exit()

while PressedButtons[a]==False :
    PressedButtons[a]=True
    count+=1
    a=lamps[a]
    if a==2:
        print(count)
        exit()
print('-1')
import math
n,k=map(int,input().split()) 
lst=list()

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(1, k+1):
    if i > N - K + 1:
        lst.append(0)
    else:
        lst.append(comb(n-k+1, i) * comb(k-i+(i-1), i-1))  

for i in range(k):
    print(lst[i]%(10**9+7))

### FIXED CODE ###

import math
n,k=map(int,input().split()) 

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod_num = 10 ** 9 + 7
for i in range(1, k+1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(n-k+1, i) * comb(k-i+(i-1), i-1) % mod_num)
s = '9' + input()
t = len(s)
A = '9' + '01'*int(t/2) + '0'*int(t%2)
B = '9' + '10'*int(t/2) + '1'*int(t%2)

s = int(s)
A = int(A)
B = int(B)

sa = s^A
sa = sa.count('1')
sb = s^B
sb = sb.count('1')

if sa >= sb:
    print(sa)
else:
    print(sb)

### FIXED CODE ###

s = input()
t = len(s)
a = '01'*int(t/2) + '0'*int(t%2)
b = '10'*int(t/2) + '1'*int(t%2)
cta = 0
ctb = 0
for i in range(t):
    if s[i] == a[i]:
        cta += 1
    elif s[i] == b[i]:
        ctb += 1
if cta <= ctb:
    print(cta)
else:
    print(ctb)
MOD = 10 ** 9 + 7
     
    X, Y = map(int, input().split())
     
    a = (2 * X - Y) // 3
    b = (2 * Y - X) // 3
     
    if not ((2 * X - Y) % 3 == 0 and (2 * Y - X) % 3 == 0 and a >= 0 and b >= 0):
        print(0)
        exit()
     
    maxf = a + b + 1
    f = [1 for _ in range(maxf)]
    invf = [1 for _ in range(maxf)]
     
    for i in range(1, maxf):
        f[i] = (i * f[i - 1]) % MOD
    invf[maxf - 1] = pow(f[maxf - 1], MOD - 2, MOD)
     
    for i in range(maxf - 1, 0, -1):
        invf[i - 1] = (i * invf[i]) % MOD
     
     
    def comb(a, b):
        return (f[a + b] * invf[a] * invf[b]) % MOD
     
     
    print(comb(a, b))

### FIXED CODE ###

MOD = 10 ** 9 + 7

X, Y = map(int, input().split())

a, b = (2 * X - Y) // 3, (2 * Y - X) // 3
maxf = a + b + 10

if (not ((2 * X - Y) % 3 == 0 and (2 * Y - X) % 3 == 0)) or (a < 0 or b < 0):
    print(0)
    exit()

f, invf = [1] * maxf, [1] * maxf

for i in range(1, maxf):
    f[i] = (f[i - 1] * i) % MOD
invf[maxf - 1] = pow(f[maxf - 1], MOD - 2, MOD)
for i in range(maxf - 1, 0, -1):
    invf[i - 1] = (invf[i] * i) % MOD

comb = lambda a, b: f[a + b] * invf[a] * invf[b] % MOD

print(comb(a, b) % MOD)
import numpy as np
n,m = map(int,input().split())

p = [0 for i in range(n+1)]
q = list()
q2 = list()

g=[[] for i in range(n+1)]

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


q2.append(1)

while 1:
    q=q2
    q2=[]

    while len(q):
        v = q.pop()
        
        for nv in g[v]:
            if p[nv] == 0:
                p[nv]=v
                g[nv].remove(v)
                q2.append(nv)
    if len(q2)==0:
        break

if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)


### FIXED CODE ###

import numpy as np
n,m = map(int,input().split())

p = [0 for i in range(n+1)]
q = list()
q2 = list()

g=[[] for i in range(n+1)]

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


q2.append(1)

while 1:
    q=q2
    q2=[]

    while len(q):
        v = q.pop()
        
        for nv in g[v]:
            if p[nv] == 0:
                p[nv]=v
                g[nv].remove(v)
                q2.append(nv)
    if len(q2)==0:
        break

if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)
a = input()
b = input()
A = int(a)
B = int(b)
print((A*B)-A-B + 1)

### FIXED CODE ###

l = input().split()
A = int(l[0])
B = int(l[1])
print((A * B)- A -B + 1)
n = int(input())
h = list(map(int,input().split(' ')))

dp = {}
myinf = int(1e9)

def frog1(i):
    if i==n-1:
        return 0
    if i>n-1:
        return myinf
    
    if i in dp:
        return dp[i]
    
    a = frog1(i+1)
    b = frog1(i+2)
    h1 = myinf if i+1>n-1 else h[i+1]
    h2 = myinf if i+2>n-1 else h[i+2]
    
    a = a + abs(h[i]-h1)
    b = b + abs(h[i]-h2)
    dp[i] = min(a,b)
    return dp[i]
print(frog1(0))


### FIXED CODE ###

import math
n = int(input())
h = list(map(int,input().split(' ')))
'''
n-=1
inf = int(1e9+5)

dp = {}
def frog1(i):
    if i==n:
        return 0
    if i in dp:
        return dp[i]
    
    a = 0
    b = 0
    if i+1>n:
        a = inf
    else:
        a = frog1(i+1)+abs(h[i]-h[i+1])

    if i+2>n:
        b = inf
    else:
        b = frog1(i+2)+abs(h[i]-h[i+2])
    dp[i] = min(a,b)
    return dp[i]
'''
def solve(n,h):
    dp = [0]*n
    for i in reversed(range(0,n-1)):
        if i==n-1:
            dp[i] = 0
        else:
            if i==n-2:
                dp[i] = abs(h[n-1]-h[n-2])
                continue
            a = 0
            b = 0
            if i+1<=n-1:
                a = dp[i+1]+abs(h[i]-h[i+1])
            if i+2<=n-1:
                b = dp[i+2]+abs(h[i]-h[i+2])  
            dp[i] = min(a,b)
    return dp[0]
print(solve(n,h))
import fractions
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
def func(x,y):
    return (x*y)//fractions.gcd(x,y)
AB = reduce(func, A, 1)
sumB = 0
for ii in range(N):
    sumB += (AB/A[ii])%(10**9+7)
print(int(sumB%(10**9+7)))

### FIXED CODE ###

import fractions
N = int(input())
A = list(map(int, input().split()))
AB = 1
for i in A:
    AB = AB*i//fractions.gcd(AB,i)
sumB = 0
for i in A:
    sumB += AB//i
print(int(sumB%(10**9+7)))
n = int(input())
d = {}
for i in range(n):
  s = input()
  d[s] = 1 if not s in d else d[s] += 1

ans = []
c = max(d.values())
for k,v in d.items():
  if v == c:
    ans += [k]
for x in sorted(ans):
  print(x)

### FIXED CODE ###

n = int(input())
d = dict()
for i in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1

ans = []
c = max(d.values())
for k, v in d.items():
    if v == c:
        ans += [k]
for x in sorted(ans):
    print(x)
a=input()
b=input()
print(6-a-b)

### FIXED CODE ###

a=int(input())
b=int(input())
print(6-a-b)
n,m=map(int,input().split())
l=list(map(int,input().split()))
count=0
if l[i]>m:
  count+=-m+l[i]
  l[i]=m
for i in range(1,n):
  if l[i-1]+l[i]>m:
    count+=l[i]+l[i-1]-m
    l[i]=m-l[i-1]   
print(count)


### FIXED CODE ###

n,m=map(int,input().split())
l=list(map(int,input().split()))
count=0
if l[0]>m:
  count+=-m+l[0]
  l[0]=m
for i in range(1,n):
  if l[i-1]+l[i]>m:
    count+=l[i]+l[i-1]-m
    l[i]=m-l[i-1]   
print(count)
a,b,c=map(int,input().slit())
k=int(input())
if a<b:
    if b<c:
        print('Yes')
    else:
        count=0
        while b>=c:
            b*=2
            count+=1
        if count<=k:
            print('Yes')
        else:
            print('No')
else:
    count=0
    while a>=b:
        b*=2
        count+=1
    while b>=c:
        c*=2
        count+=1
    if count<=k:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

a,b,c=map(int,input().split())
k=int(input())
if a<b:
    if b<c:
        print('Yes')
    else:
        count=0
        while b>=c:
            c*=2
            count+=1
        if count<=k:
            print('Yes')
        else:
            print('No')
else:
    count=0
    while a>=b:
        b*=2
        count+=1
    while b>=c:
        c*=2
        count+=1
    if count<=k:
        print('Yes')
    else:
        print('No')
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

c = 0
t = int(sum(a)//n)
for i in range(0,N):
  if a[i]!=t:
    c=abs(t-a[i])

print(c)


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))

c1 = 0
c2 = 0
t1 = int(math.ceil(sum(a)/n))
t2 = int(sum(a)//n)
for i in range(0,n):
  if a[i]!=t1:
    c1=c1+(t1-a[i])*(t1-a[i])
  if a[i]!=t2:
    c2=c2+(t2-a[i])*(t2-a[i])

print(min(c1,c2))
c = input()
if c==a,i,u,e,o
print(vowel)
else
	print(consonant)

### FIXED CODE ###

c = input()
if c in['a','i','u','e','o']:
	print('vowel')
else:
  	print('consonant')
a=input()
b=map(int,raw_input().split())
c=[]
for i in range(100000):
    c.append(0)

for i in b:
    c[i]+=1
    c[i+1]+=1
    c[i+2]+=1

c.sort()
c.reverse()

print c[0]

### FIXED CODE ###

a=input()
b=map(int,raw_input().split())
c=[]
for i in range(100002):
    c.append(0)

for i in b:
    c[i]+=1
    c[i+1]+=1
    c[i+2]+=1

c.sort()
c.reverse()

print c[0]
n,m = map(int,input().split())
a=0
b=0
if m==0:
    print(0,0)
    exit()
p = [[str(i) for i in input().split()] for _ in range(m)]

c = sorted(p,key=lambda x:x[0])

now = c[0][0]
d = 1
aa=0
bb=0
f = 0
print(now)
for i in c:
    if i[0] == now:
        if i[1]=='AC':
            if d:
                a += 1
                f = 1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
        if f:
            b += bb
            f = 0
            bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
	if f:
            b += bb
            f = 0
            bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
b += bb
print(a,b)


### FIXED CODE ###

n,m = map(int,input().split())
a=0
b=0
if m==0:
    print(0,0)
    exit()
p = [[str(i) for i in input().split()] for _ in range(m)]

c = sorted(p,key=lambda x:x[0])

now = c[0][0]
d = 1
aa=0
bb=0
f = 0

for i in c:
    if i[0] == now:
        if i[1]=='AC':
            if d:
                a += 1
                f = 1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
        if f:
            b += bb
            f = 0
        bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
if f:
  b+=bb
print(a,b)
import math
a,b,c,d=map(int,input().split())
al = b-a+1
# cで割り切れる個数
x = int(b/c) -int((a-1)/c)
# dで割り切れる個数
y = int(b/d) -int((a-1)/d)
# cdの最小公倍数
lcm_xy = int(c*d/math.gcd(c,d))
# cdの最小公倍数で割り切れる個数
xy = int(b/lcm_xy) -int((a-1)/lcm_xy)
#print(x,y,xy,al)
print(al-(x+y-xy))

### FIXED CODE ###

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

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

a_c = (a-1)//c
a_d = (a-1)//d
a_cd = (a-1)//(c*d//gcd(c,d))

b_c = b//c
b_d = b//d
b_cd = b//(c*d//gcd(c,d))

bb = b - (b_c + b_d - b_cd) 
aa = (a-1) - (a_c + a_d - a_cd)

print(bb - aa)
def gcd(a,b):
  if a==0:return b
  return gcd(b%a,a)
n = int(input())
a = list(map(int, input().split()))
#print(a)
b=[]
for i in range(n):
    #print(i)
    b.append(a[i])
for i in range(n):
    if i != 0:
        b[i]=int(b[i-1]/int(gcd(b[i-1],b[i])))*b[i]
lcm=b[n-1]
ans=0
for i in range(n):
    #print(a[i])
    ans=(ans+lcm/a[i])%(10**9+7)
print(int(ans))


### FIXED CODE ###

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

N = pow(10,9)+7
def gcd(a,b):
    if a==0:return b
    return gcd(b%a,a)

def lcm(a,b):
    tmp =  (a*b)//gcd(a,b)
    return tmp

hcm = arr[0]
for i in range(1,n):
    hcm = lcm(hcm,arr[i])

res = 0
for num in arr:
    res += (hcm//num)
    

print(res%N)
import sys
from operator import itemgetter
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
def main():
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while(e[0] > d):
			if cont == True:
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			else:
				mini = min(kouho)
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			cont = True
			if q < Q-1:
				q = q + 1
				d = int(inputs())
			else:
				flag = True
				q = q + 1
				break
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			cont = False
	for t in [None]*(Q-q):
		print(-1)
		
def sub():
	V = [list(map(int,inputs().split())) for p in [0]*N]
	M = [int(inputs()) for p in [0]*Q]
	V.sort(key = lambda x:(x[2],x[0],x[1]))
	for v in V:
		v[0] -= v[2]
		v[1] -= v[2] + 1
	for m in M:
		for n in range(N):
			if V[n][0] <=m and m <= V[n][1]:
				print(V[n][2])
				break
		else:
			print(-1)


if N>200000:
	sub()
else:
	main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
a,p = map(int,input().split())
ans = (3*a + p)//2
print(ans)
N = int(input())
h = list(map(int, input().split()))

def solve_range(h, start):
	ans = 0
	for i in range(start, len(h)):
		if h[i] > 0:
			h[i] -= 1
		else:
			break
	start = min((i for i in range(len(h)) if h[i] >0), default = -1)
	if start == -1:
		return ans+1
	else:
		ans += solve_range(h, start) + 1
		return ans

start = min((i for i in range(len(h)) if h[i] > 0), default = -1)
a=solve_range(h,start)
print(a)

### FIXED CODE ###

# Grand Garden
N = int(input().strip())
h = list(map(int, input().strip().split()))

def mizu(h, s):
	for k in range(s, len(h)):
		if h[k] > 0:
			h[k] -= 1
		else:
			break
	return h
	
def find_start(h):
	s = 0
	for k in range(len(h)):
		if h[k] > 0:
			s = k
			break
	return s

def is_finish(h):
	if sum(h) == 0:
		return True
	else:
		return False

count = 0
while True:
	if is_finish(h):
		break
	s = find_start(h)
	h = mizu(h, s)
	count += 1

print(count)
import sys
sys.setrecursionlimit(10001)
n,m,k=map(int,input().split())

L=[[] for i in range(1+n)]
N=[]
Ncnt=[0 for i in range(1+n)]
C=[0 for i in range(1+n)]

for inp in range(m):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)

for inp in range(k):
    a,b=map(int,input().split())
    N.append((a,b))

def tansa(x,gone,color):
    C[x]=color
    for nex in L[x]:
        if nex in gone:
            continue
        else:
            tansa(nex,gone+[nex],color)

now=1
for i in range(1,n):
    if C[i]==0:
        tansa(i,[i],now)
        now+=1

CC=sorted(C)

cnt=0
ccres=[]
for i in range(now):
    ccres.append(CC.index(i))
ccres.append(n+1)
dic={i:ccres[i+1]-ccres[i] for i in range(1,now)}

#print(C)
#print(dic)

for i in range(k):
    if C[N[i][1]] == C[N[i][0]]:
        Ncnt[N[i][1]]+=1
        Ncnt[N[i][0]]+=1

for i in range(1,n):
    print(dic[C[i]]-len(L[i])-Ncnt[i]-1,end=" ")
i=n
print(dic[C[i]]-len(L[i])-Ncnt[i]-1,end="")

### FIXED CODE ###

n,m,k=map(int,input().split())
BAD=[0 for i in range(n+1)]

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

B=[] 
for inp in range(k):
    a,b=map(int,input().split())
    B.append((a,b))
    
uf=[i for i in range(n+1)]
def uf_find(x,uf=uf):
    while uf[x]!=x:
        x=uf[x]
    return x       


res=[]

for ele in E:
    if uf_find(ele[0]) == uf_find(ele[1]):
        continue
    else:
        res.append((ele[0],ele[1])) #write result
        
        if uf_find(ele[0])>uf_find(ele[1]):
            uf[uf_find(ele[0])]=uf_find(ele[1])
        else:
            uf[uf_find(ele[1])]=uf_find(ele[0])

SCO=[0 for i in range(n+1)]
for i in range(1,n+1):
    SCO[uf_find(i)]+=1


for bl in B:
    if uf_find(bl[0])==uf_find(bl[1]):
        BAD[bl[0]]-=1
        BAD[bl[1]]-=1

ANS=[str(SCO[uf_find(i)] + BAD[i] -1) for i in range(1,n+1)]
print(" ".join(ANS))
A = int(input())
i = 0
S = 0
B = int(math.sqrt(A))
while i == 0:
    S = 0
    B = int(math.sqrt(A))
    for n in range(2,B + 1):
        if A % n == 0:
            A += 1
            S = 1
            break
    if S == 0:
        print(A)
        exit()

### FIXED CODE ###

import math
A = int(input())
i = 0
S = 0
B = int(math.sqrt(A))
while i == 0:
    S = 0
    B = int(math.sqrt(A))
    for n in range(2,B + 1):
        if A % n == 0:
            A += 1
            S = 1
            break
    if S == 0:
        print(A)
        exit()
N = int(input().strip())

n_list = [[] for i in range(N)]
d = [0] * N

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


#print(n_list)
#print(d)

d_dict = {}
for i in range(N):
    d_dict[i] = d[i]
tmp = sorted(d_dict.items(), key = lambda x:x[1], reverse = True)

colors = [0] * (N)

root = tmp[0][0]

def paint(node, parent_edge_id):
    #print(node, parent_edge_id)
    tmp_color = 1
    for edge in n_list[node]:
        #print("ege:", edge)
        if edge[1] != parent_edge_id:
            try: 
                if parent_edge_id != -1 and tmp_color == colors[parent_edge_id]:
                    tmp_color += 1
                colors[edge[1]] = tmp_color
            except Exception as e:
                print(0)
            paint(edge[0], edge[1])
            tmp_color += 1

    

paint(tmp[0][0], -1)
print(tmp[0][1]) # color num 
for i in range(N-1):
    print(colors[i])

### FIXED CODE ###

import sys
N = int(input().strip())

n_list = [[] for i in range(N)]
d = [0] * N

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


#print(n_list)
#print(d)

d_dict = {}
for i in range(N):
    d_dict[i] = d[i]
tmp = sorted(d_dict.items(), key = lambda x:x[1], reverse = True)

colors = [0] * (N)

root = tmp[0][0]

def paint(node, parent_edge_id):
    #print(node, parent_edge_id)
    tmp_color = 1
    for edge in n_list[node]:
        #print("ege:", edge)
        if edge[1] != parent_edge_id:
            if parent_edge_id != -1 and tmp_color == colors[parent_edge_id]:
                tmp_color += 1
            colors[edge[1]] = tmp_color
            paint(edge[0], edge[1])
            tmp_color += 1

    
sys.setrecursionlimit(10**7)
paint(tmp[0][0], -1)
print(tmp[0][1]) # color num 
for i in range(N-1):
    print(colors[i])
n=int(input())
s=input()
x=n
flag1=False
flag2=False
for i in range(n):
    if s[i]=="#" and flag1==False:
        x=i
        flag1=True
    if s[n-1-i]!="#" and flag2==False:
        y=n-i
        flag2=True
    if flag1==True and flag2==True:
        break

b=s[x:y].count("#") 
w=len(s[x:y])-b
print(b if b<w else w)

### FIXED CODE ###

n=int(input())
s=input()


w=s.count(".")
ans = w

for i in range(n):

    if s[i]=="#":
        w+=1
    if s[i]==".":
        w-=1
    ans=min(ans,w)
    
print(ans)
n, k, s = map(int, input().split())

if s == 10 ** 9:
    ans = []
    for _ in range(k):
        ans.append(str(s))
    for _ in range(n-k):
        ans.append('1')
    print(' '.join(ans))
else:
    ans = []
    for _ in range(k):
        ans.append(str(s))
    for _ in range(n-k):
        ans.appned(str(s+1))
    print(' '.join(ans))

### FIXED CODE ###

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

if s == 10 ** 9:
    ans = []
    for _ in range(k):
        ans.append(str(s))
    for _ in range(n-k):
        ans.append('1')
    print(' '.join(ans))
else:
    ans = []
    for _ in range(k):
        ans.append(str(s))
    for _ in range(n-k):
        ans.append(str(s+1))
    print(' '.join(ans))
A,B = map(int,input())
R = [0,13,1,2,3,4,5,6,7,8,9,10,11,12]
if R[A]>R[B]:
  print("Alice")
elif R[A]<R[B]:
  print("Bob")
else:
  print("Draw")

### FIXED CODE ###

A,B = map(int,input().split())
R = [0,13,1,2,3,4,5,6,7,8,9,10,11,12]
if R[A]>R[B]:
  print("Alice")
elif R[A]<R[B]:
  print("Bob")
else:
  print("Draw")
import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    idx=L.index('AC')
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))

### FIXED CODE ###

import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    if('AC' in L):
        idx=L.index('AC')
    else:
        idx=-1
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))
h, w = map(int, input().split())
L = ['.'*(w+1)]
for i in range(h):
  L.append('.'+input()+'.')
L.append('.'*(w+1))  

out = 1
for i in range(1, h+1):
  for j in range(i+1, h+1):
    if L[i][j] == '#':
      if L[i][j+1] == '#' or L[i][j-1] == '#' or L[i-1][j] == '#' or L[i+1][j] == '#':
        out *= 1
      else:
        out *= 0

if out == 1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

h, w = map(int, input().split())
L = ['.'*(w+1)]
for i in range(h):
  L.append('.'+input()+'.')
L.append('.'*(w+1))  

out = 1
for i in range(1, h+1):
  for j in range(1, w+1):
    if L[i][j] == '#':
      if L[i][j+1] == '#' or L[i][j-1] == '#' or L[i-1][j] == '#' or L[i+1][j] == '#':
        out *= 1
      else:
        out *= 0

if out == 1:
  print('Yes')
else:
  print('No')
n = int(input())
d = {}
for i range(n):
  s = input()
  if s not in d:d[s] = 0
  d[s] += 1
max_cnt = sorted(d.items(), key=lambda tp:tp[1])[-1][1]
a1 = filter(lambda tp:tp[1] == max_cnt, d.items())
a2 = map(lambda tp:tp[0], a1)
for s in sorted(a2):
  print(s)

### FIXED CODE ###

n = int(input())
d = {}
for i in range(n):
  s = input()
  if s not in d:d[s] = 1
  d[s] += 1
max_cnt = sorted(d.items(), key=lambda x:x[1])[-1][1]
s = [x for x, y in d.items() if y == max_cnt]
s.sort()
for name in s:
    print(name)
N,X = map(int,input().split())
L = list(map(int,input().split()))

D = 0
i = 0
while D<=X:
  if X<D:
    break
  D += L[i-1]
  i += 1
print(i)


### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))

D = 0
i = 0
while D<=X and i<N+1:
  #print('   {}'.format(D))
  if i<N:
	  D += L[i]
  i += 1
print(i)
N,M = [int(x) for x in input().split()]

dic = {}
for _ in range(N):
    A,B = [int(x) for x in input().split()]
    if A <= M: dic.setdefault(A, []).append(B)

buf = []
for m in sorted(dic.keys(),reverse=True):
     buf.extend(sorted(dic[m],reverse=True)[:M-m+1])
print(sum(sorted(buf,reverse=True)[:M]))

### FIXED CODE ###

import re
RL_list = input()
RL_list = re.findall(r'R*L*',RL_list)
buf = []

for lis in RL_list:
    if len(lis)==2:
        buf.extend([1,1])
    if len(lis)>2:
        r_cnt = lis.count('R')
        l = len(lis) - r_cnt
        if (len(lis) % 2 == 1) & (r_cnt % 2 == 1):
            r = len(lis) // 2 + 1
        #elif (len(lis) % 2 == 1) & (r_cnt % 2 == 0):
        else:
            r = int(len(lis) / 2)
        
        buf.extend([0]*(r_cnt-1))
        buf.extend([r,len(lis)-r])
        buf.extend([0]*(len(lis)-r_cnt-1))
        
print(" ".join(map(str,buf)))
def sum():
    S = [int(n) for n in input().split()]
    total = sum(S)
    if total >= 22:
        print("bust")
    else:
        print("win")

sum()

### FIXED CODE ###

S = [int(n) for n in input().split()]
total = sum(S)
if total >= 22:
    print("bust")
else:
      print("win")
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==-1:
		break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print ("{:07b}".format(a^e))
		e=a

### FIXED CODE ###

ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=input()
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[input()]
			print "{:07b}".format(a^e)
			e=a
	except:
		pass