Harryxun/stf_run huggingface dataset:
class UnionFind:

    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.ranks = [0] * n
        self.count = n

    def union(self, x, y):
        self.link(x,y)

    def link(self, x, y):
        if self.parents[x] == self.parents[y]:
            return
        if self.ranks[x] < self.ranks[y]:
            self.parents[x] = y
        else:
            if self.ranks[y] == self.ranks[x]:
                self.ranks[y] += 1
            self.parents[y] = x
        # print('linked')
        self.count -= 1

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

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

bridges = []
for i in range(M):
    bridges.append(list(map(int, input().split())))


# bridges = bridges[::-1]
# result = []
# print('-----')
count = 0
for i in range(M):
    # print(i, 'th ------')
    uf = UnionFind(N)
    for j in range(M):
        x, y = bridges[j]
        if j == i:
            # print('  skip',x-1,y-1, 'count',uf.count, uf.parents)
            continue
        else:
            uf.union(x, y)
            # print('  union',x-1,y-1, 'count',uf.count, uf.parents)
    # print(i, uf.count)
    if uf.count > 1:
        count += 1


# for x, y in bridges:
#     uf.union(x-1, y-1)
#     result.append(uf.get_group_num())

# print(result[::-1])

print(count)


### FIXED CODE ###

N,M = map(int,input().split())
es = []
for i in range(M):
    a,b = map(int,input().split())
    a,b = a-1, b-1
    es.append((a,b))
 
parent = None
def root(a):
    if parent[a] == a:
        return a
    else:
        parent[a] = root(parent[a])
        return parent[a]
def is_same(a,b):
    return root(a) == root(b)
def unite(a,b):
    ra = root(a)
    rb = root(b)
    if ra == rb: return
    parent[ra] = rb;
 
ans = 0
for i in range(M):
    parent = [k for k in range(N)]
    for j,e in enumerate(es):
        if j == i: continue
        a,b = e
        unite(a,b)
    a,b = es[i]
    if not is_same(a,b):
        ans += 1
print(ans)
def seek_dup(s):
    t_list = [t for (t, d) in s]
    #d_list = [d for (t, d) in s]
 
    for t, d in reversed(s):
        if t_list.count(t) > 1:
            return (t, d)
        else:
            continue
        
    return None
 
N, K = map(int, input().split())
menu_ = []
 
for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))
 
menu = sorted(menu_, key = lambda x:x[1], reverse=True)
p = sum([d for (t, d) in menu[:K]]) + len(set([t for (t, d) in menu[:K]]))**2
 
selected_menu = menu[:K]
#t_list = [t for (t, d) in selected_menu]
#d_list = [d for (t, d) in selected_menu]
ans = p
for m in menu[K:]:
    t_list = [t for (t, d) in selected_menu]
    d_list = [d for (t, d) in selected_menu]
    
    if m[0] not in t_list:
        d = seek_dup(selected_menu)
        if d == None:
            continue
        
        selected_menu.remove(d)
        selected_menu.append(m)
    
    p += (m[1] - d[1]) + 2 * len(set(t_list)) - 1 
    #print(ans, p)
    ans = max(ans, p)
 
print(ans) 

### FIXED CODE ###

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

for i in range(N):
    t, d = map(int, input().split())
    menu_.append((t, d))

menu = sorted(menu_, key = lambda x:x[1], reverse=True)
neta = set()
duplicates = []

for m in menu[:K]:
    if m[0] in neta:
        duplicates.append(m[1])
    else:
        neta.add(m[0])

p = sum([d for (t, d) in menu[:K]]) + len(neta)**2
ans = p

for m in menu[K:]:
    if m[0] not in neta and duplicates:
        neta.add(m[0])
        duplicate = duplicates.pop()
        
        p += (m[1] - duplicate) + 2 * len(neta) - 1 
        #print(ans, p)
        ans = max(ans, p)

print(ans)
while True:
    n = int(raw_input())
    if n == 0: break
    
    a = []
    for i in range(n):
        a.append(map(int, raw_input().split()))
    
    for i in range(n):
        a[i].append(sum(a[i]))
    
    col_sum = []
    for col in range(len(a[0])):
        sum = 0
        for row in range(len(a)):
            sum += a[row][col];
        col_sum.append(sum)
    a.append(col_sum)

    for row in range(len(a)):
        for col in range(len(a[0])):
            print "%5d" % a[row][col],
        print

### FIXED CODE ###

import sys

while True:
    n = int(raw_input())
    if n == 0: break
    
    a = []
    for i in range(n):
        a.append(map(int, raw_input().split()))
    
    for i in range(n):
        a[i].append(sum(a[i]))
    
    col_sum = []
    for col in range(len(a[0])):
        s = 0
        for row in range(len(a)):
            s += a[row][col];
        col_sum.append(s)
    a.append(col_sum)

    for row in range(len(a)):
        for col in range(len(a[0])):
            sys.stdout.write("%5d" % a[row][col])
        print
NX = list(int(i) for i in input().split())
for i in range(NX[0]):
     m.append(int(input()))

weight0 = 0
for i in range(NX[0]):
    weight0 += m[i]
rest = NX[1] - weight0
minimumfood = min(m)
ans = int(rest/minimumfood) + NX[0]
print(ans)


### FIXED CODE ###


m = []
NX = list(int(i) for i in input().split())
for i in range(NX[0]):
     m.append(int(input()))

weight0 = 0
for i in range(NX[0]):
    weight0 += m[i]
rest = NX[1] - weight0
minimumfood = min(m)
ans = int(rest/minimumfood) + NX[0]
print(ans)
import bisect
n,m=map(int, input().split())
pl=[0]*m
yl=[0]*m
ol=[[] for i in range(n+1)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(n):
    ol[pl[i]] = sorted(ol[pl[i]])
for i in range(m):
    x = bisect.bisect_right(ol[pl[i]], yl[i])
    print("%06d%06d" % (pl[i], x))


### FIXED CODE ###

import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(1,n+1):
    ol[i].sort()
for i in range(m):
    print("%06d%06d" % (pl[i], bisect.bisect_right(ol[pl[i]], yl[i])))
n = input()
print((n - 2)*180)

### FIXED CODE ###

n = int(input())
ans = ( n - 2 ) * 180
print(ans)
S = input()
P = ['dream', 'dreamer', 'erase', 'eraser']

def makeS(T, flg):
    if len(T) > len(S):
        return 0
    
    for p in P:
        T += p
        if T == S:
            return 1
        else:
            flg += makeS(T, flg)
            T = T[:len(T)-len(p)]
    return flg

if makeS('', 0):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

S = input()
P = ['dream', 'dreamer', 'erase', 'eraser']
s = S
for i in range(10**5):
    flg = True
    for p in P:
        if s[len(s)-len(p):] == p:
            s = s[:len(s)-len(p)]
            flg = False
            break
    if flg:
         print('NO')
         quit()
    if len(s) == 0:
        break
print('YES')
import math
x1, y1, x2, y2 = map(int, input().split())
z = math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(z)


### FIXED CODE ###

import math
x1, y1, x2, y2 = map(float, input().split())
z = math.sqrt((x1-x2)**2 + (y1-y2)**2)
print(z)
A = [list(map(str,input().split())) for i in range(3)]
N = int(input())
b = list(map(int,input().split()))
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if str(b[i]) in A:
    l.append(tuple(nd[0] for nd in np.where(A == str(b[i]))))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
    
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if b[i] in A:
    l.append(tuple(nd[0] for nd in np.where(A == b[i])))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")
import sys

def main():
    # sys.stdin = open('input149c.txt')

    x = int(input())

    r = false
    while not r:
        r = true
        for i in range(2,x):
            if x % i == 0:
                r = false
                break

        if r == false:
            x += 1
        
    print(x)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def main():
    # sys.stdin = open('input149c.txt')

    x = int(input())

    r = False
    while not r:
        r = True
        for i in range(2,x):
            if x % i == 0:
                r = False
                break

        if r == False:
            x += 1
        
    print(x)

if __name__ == '__main__':
    main()
A, B, M = map(int, input().split())
a = [int(i) for i in input().split]
b = [int(i) for i in input().split]

ans = min(a) + min(b)

for i in range(m):
  x, y, c = map(int, input().split())
  val = a[x-1] + b[y-1] - c
  ans = min(ans, val)
print(ans)

### FIXED CODE ###

A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = min(a) + min(b)

for i in range(M):
  x, y, c = map(int, input().split())
  val = a[x-1] + b[y-1] - c
  ans = min(ans, val)
print(ans)
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
    s=min(a)
    a = list(map(lambda x:x-min(a), a))
    a = [i for i in a if i != 0]+[s]
print(int(a))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
amin=min(a)
while len(a)>1:
    s=min(a)
    a = list(map(lambda x:x%s, a))
    a = [i for i in a if i > 0]+[s]
print(a[0])
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H,W=MI()
    A=LLIN(H)
    odds=[]
    ans=[]
    for i in range(H):
        if i&1:
            for j in range(W)[::-1]:
                if A[i][j]&1:
                    if j==0:
                        dy=1
                        dx=0
                    else:
                        dy=0
                        dx=-1
                    if i+dy!=H:
                        
                        ans.append((i+1,j+1,i+dy+1,j+dx+1))
                        A[i+dy][j+dx]+=1
        else:
            for j in range(W)[::-1]:
                if A[i][j]&1:
                    if j==W-1:
                        dy=1
                        dx=0
                    else:
                        dy=0
                        dx=1
                    if i+dy!=H:
                       
                        ans.append((i+1,j+1,i+dy+1,j+dx+1))
                        A[i+dy][j+dx]+=1

    print(len(ans))
    for a in ans:
        print(*a)
    


if __name__ == '__main__':
  main()

### FIXED CODE ###

A, B = map(int, input().split())
if 2 not in [A, B]:
    print("Yes")
else:
    print("No")
import math

n = int(input())
a = []
tmp = input().split()
for i in range(n):
    a.append(int(tmp[i]))

if n == 2:
    if a[0] > a[1]:
        print(a[0])
    else:
        print(a[1])
    exit()

rev = []
rev.append(a[n-1])
prev_gcd = a[n-1]
for i in range(n-2, 0, -1):
    prev_gcd = math.gcd(prev_gcd, a[i])
    rev.append(prev_gcd)

ans = math.gcd(a[0], rev[-2])
if ans < rev[-1]:
    ans = rev[-1]
        
prev_gcd = a[0]
for i in range(1, n-1):
    prev_gcd = math.gcd(prev_gcd, a[i])
    cand_ans = math.gcd(prev_gcd, rev[-1 - i])
    if cand_ans > ans:
        ans = cand_ans

print(ans)
                  


### FIXED CODE ###

elem = input().split()
a = int(elem[0])
b = int(elem[1]) 
t = int(elem[2])
    
ans = (t // a) * b


print(ans)
import sys
from collections import *
import heapq
import math

import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

ans=0
# cnt=0
for i in range(int(n**0.5)):
    x=(n-(i+1))//(i+1)
    if n//x==n%x:
        ans+=x
    # print(n//cnt,cnt)
print(ans)

### FIXED CODE ###

import sys
from collections import *
import heapq
import math

import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

ans=0
# cnt=0
if n==1:
    print(0)
    quit()
for i in range(int(n**0.5)):
    x=(n-(i+1))//(i+1)
    if n//x==n%x:
        ans+=x
    # print(n//cnt,cnt)
print(ans)
inport sys
str = []
for line in sys.stdin.readlines()
    str.append(line.rstrip())
num = len(str)
for i in range(num)
    s = str.split(" ")
    a = int(s[0])
    b = s[1]
    c = s[2]
    if b =="?":
        break
    if b == "+":
        print(a+c)
    if b == "-":
        print(a-c)
    if b == "*":
        print(a*c)
    if b == "/"
        print(int(a/c))

### FIXED CODE ###

for i in range(100000):
    s = input().rstrip().split(" ")
    a = int(s[0])
    b = s[1]
    c = int(s[2])
    if b =="?":
        break
    if b == "+":
        print(a+c)
    if b == "-":
        print(a-c)
    if b == "*":
        print(a*c)
    if b == "/":
        print(int(a/c))
3 1
1 2

### FIXED CODE ###


from collections import deque

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

w = [[] for i in range(n)]
c = [0 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    w[a-1].append(b-1)
    w[b-1].append(a-1)
ans =-1
for i in range(n):
    if c[i] == 0:
        c[i] = 1
        ans += 1
        d.append(i)
        while d:
            x = d.pop()
            for i in w[x]:
                if c[i] == 0:
                    c[i] = 1
                    d.append(i)

print(ans)
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

from collections import defaultdict

ns = defaultdict(set)
ss = [None] * rows
for i in range(rows):
    s = input()
    ss[i] = s
n = rows * cols
start = ch*w+cw
goal = dh*w+dw
seen = [None]*n
seen[start] = 0
from queue import deque 
q = deque([(0, start)]) # ワープ回数, 現在位置, 最後の道の位置
# dx = [0,1,0,-1]
# dy = [1,0,-1,0]
dx = []
dy = []
vvs = []
for i in range(-2,3):
    for j in range(-2,3):
        if not (i==j==0):
            dx.append(i)
            dy.append(j)
            if abs(i)+abs(j)>1:
                vvs.append(1)
            else:
                vvs.append(0)
while q:
    pnum,pu = q.popleft()
    ux,uy = divmod(pu,w)
    # print(pnum,divmod(pu,w))
    if pu==goal:
        break
    for xx,yy,vv in zip(dx,dy,vvs):
#         x = ux+xx
#         y = uy+yy
        x,y = ux+xx, uy+yy
        u = x*w + y
        num = pnum+vv
        if x<0 or y<0 or x>=h or y>=w or ss[x][y]=="#":
            continue
#         print(x,y)
        if seen[u] is None or seen[u]>num:
            seen[u] = num
            if vv==0:
                q.appendleft((num, u))
            else:
                q.append((num,u))
val = seen[goal]
if val is None:
    print(-1)
else:
    print(val)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

from collections import defaultdict

ns = defaultdict(set)
ss = [None] * rows
for i in range(rows):
    s = input()
    ss[i] = s
n = rows * cols
start = ch*w+cw
goal = dh*w+dw
seen = [None]*n
seen[start] = 0
from heapq import heappop as hpp, heappush as hp
q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
# dx = [0,1,0,-1]
# dy = [1,0,-1,0]
dx = []
dy = []
vvs = []
for i in range(-2,3):
    for j in range(-2,3):
        if not (i==j==0):
            dx.append(i)
            dy.append(j)
            if abs(i)+abs(j)>1:
                vvs.append(1)
            else:
                vvs.append(0)
while q:
    pnum,pu = hpp(q)
    ux,uy = divmod(pu,w)
    # print(pnum,divmod(pu,w))
    if pu==goal:
        break
    for xx,yy,vv in zip(dx,dy,vvs):
#         x = ux+xx
#         y = uy+yy
        x,y = ux+xx, uy+yy
        u = x*w + y
        num = pnum+vv
        if x<0 or y<0 or x>=h or y>=w or ss[x][y]=="#":
            continue
#         print(x,y)
        if seen[u] is None or seen[u]>num:
            seen[u] = num
            hp(q, (num, u))
val = seen[goal]
if val is None:
    print(-1)
else:
    print(val)
a = []
while True:
    m,n,o = input()
    m=int(m)
    o=int(o)
    if n == "?":
        break
    if n=="+":
    	a.append(m+o)
    elif n=="-":
    	a.append(m-o)
    elif n=="*":
    	a.append(m*o)
    elif n=="/":
    	a.append(m/o)

for i in a:
	print(a)

### FIXED CODE ###

a = []
while True:
    m,n,o = input().split()
    m=int(m)
    o=int(o)
    if n == "?":
        break
    if n=="+":
    	a.append(m+o)
    elif n=="-":
    	a.append(m-o)
    elif n=="*":
    	a.append(m*o)
    elif n=="/":
    	a.append(int(m/o))
 

for i in a:
	print(i)
a, b = input().split()
a = int(a)
b_i = int(b[:-3])
b_f = int(b[-2:])
if b_f == 0:
  print(a*b_i)
  exit()
b_m = a*b_f
print(a*b_i + int(str(b_m)[:-2]))

### FIXED CODE ###

a, b = input().split()
a = int(a)
b_i = int(b[:-3])
b_f = int(b[-2:])
if b_f == 0:
  print(a*b_i)
  exit()
b_m = a*b_f
if b_m < 100:
  print(a*b_i)
  exit()
print(a*b_i + int(str(b_m)[:-2]))
n, a, b = input().split()
 
s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(s)

### FIXED CODE ###

n, a, b = map(int, input().split())
 
s = 0
for i in range(n+1):
  digitsum = i%10 + (i//10)%10 + (i//100)%10 + (i//1000)%10 + (i//10000)%10
  if a <= digitsum <= b:
    s += i
    
print(s)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

N = 10**9+7
R = 10**5
modfact = [0]*(R+1)
def modfact_memo(n,N):
    r = 1
    modfact[0] = 1
    for i in range(1,n+1):
        r = r % N * i % N
        modfact[i] = r
modfact_memo(10**5,N)

# ax ≡ 1 (mod m)
modinv=[0]*(R+1)
def modinv_memo(a,m):
    for i in range(a+1):
        j = modfact[i]
        (inv, q, gcd_val) = egcd(j, m)
        modinv[i] = inv % m
modinv_memo(R,N)

def modconb(n,r,N):
    p = modfact[n]
    q1 = modinv[r]
    q2 = modinv[n-r]
    return p*q1%N*q2%N


n = int(input())
a = list(map(int,input().split()))
b=[0]*n
for i in range(n+1):
    b[a[i]-1] += 1
w = b.index(2)+1
index = []
for i in range(n+1):
    if a[i] == w:
        index.append(i)
l = index[0]
r = n - index[1]

for i in range(n+1):
    ans = modconb(n+1,i+1,N)
    if l+r >= i:
        ans -= modconb(l+r,i,N)
        ans %= N
    print(ans)

### FIXED CODE ###

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

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

N = 10**9+7
R = 10**5+10
modfact = [0]*(R+1)
def modfact_memo(n,N):
    r = 1
    modfact[0] = 1
    for i in range(1,n+1):
        r = r % N * i % N
        modfact[i] = r
modfact_memo(R,N)

# ax ≡ 1 (mod m)
modinv=[0]*(R+1)
def modinv_memo(a,m):
    for i in range(a+1):
        j = modfact[i]
        (inv, q, gcd_val) = egcd(j, m)
        modinv[i] = inv % m
modinv_memo(R,N)

def modconb(n,r,N):
    p = modfact[n]
    q1 = modinv[r]
    q2 = modinv[n-r]
    return p*q1%N*q2%N


n = int(input())
a = list(map(int,input().split()))
b=[0]*n
for i in range(n+1):
    b[a[i]-1] += 1
w = b.index(2)+1
index = []
for i in range(n+1):
    if a[i] == w:
        index.append(i)
l = index[0]
r = n - index[1]

for i in range(n+1):
    ans = modconb(n+1,i+1,N)
    if l+r >= i:
        ans -= modconb(l+r,i,N)
        ans %= N
    print(ans)
from collections import Counter
n = int(input())
A = Counter(input().split())
B = Counter(input().split())
C = Counter(input().split())
ans = ""
for key,value in A.items():
  ans.append(str(key)*min(value,B[key],C[key]))
print(sorted(ans))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))
s=input()
#print(s)
l=[-1 for _ in range(len(s)+1)]
def aa(ix,v): #ixはlベース
 # print(ix,v,l)
  if (ix>= len(s) and v==1) or (ix==0 and v==0-1):
    return
  if v==1 and s[ix]=="<" and l[ix+1]<=l[ix]:
    l[ix+1]=l[ix]+1
    aa(ix+1,1)
  elif v==-1 and s[ix-1]==">" and l[ix-1]<=l[ix]:
    l[ix-1]=l[ix]+1
    aa(ix-1,-1)
  return

for i in range(0,len(s)):
  if i ==0 and s[0]=="<":    
    l[0]=0
    aa(i,1)
  elif i==len(s)-1 and s[-1]==">":
    l[-1]=0
    aa(i+1,-1)
  elif s[i]==">" and s[i+1]=="<":
    l[i+1]=0
    aa(i+1,1)
    aa(i+1,-1)

print(sum(l))



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
s=input()
#print(s)
l=[-1 for _ in range(len(s)+1)]
def aa(ix,v): #ixはlベース
# print(ix,v,l)
  if (ix>= len(s) and v==1) or (ix==0 and v==0-1):
    return
  if v==1 and s[ix]=="<" and l[ix+1]<=l[ix]:
    l[ix+1]=l[ix]+1
    aa(ix+1,1)
  elif v==-1 and s[ix-1]==">" and l[ix-1]<=l[ix]:
    l[ix-1]=l[ix]+1
    aa(ix-1,-1)
  return

for i in range(0,len(s)):
  if i ==0 and s[0]=="<":    
    l[0]=0
    aa(i,1)
  elif i==len(s)-1 and s[-1]==">":
    l[-1]=0
    aa(i+1,-1)
  elif s[i]==">" and s[i+1]=="<":
    l[i+1]=0
    aa(i+1,1)
    aa(i+1,-1)

print(sum(l))
, b = map(int, input().split())
if a == 1 :
    a = 14
if b == 1 :
    b = 14
if a > b :
    print ('Alice')
elif a < b :
    print('Bob')
else :
    print('Draw')

### FIXED CODE ###

a, b = map(int, input().split())
if a == 1 :
    a = 14
if b == 1 :
    b = 14
if a > b :
    print ('Alice')
elif a < b :
    print('Bob')
else :
    print('Draw')