1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def solve():
    ta=input()
    ta = [eval(i) for i in ta.split()]
    tb=input()
    tb = [eval(i) for i in tb.split()]
    suma=sum(ta)
    sumb=sum(tb)
    if suma>sumb:
        print("Algosia")
        return
    elif suma<sumb:
        print("Bajtek")
        return
    else:
        ta=sorted(ta, reverse=True)
        tb=sorted(tb, reverse=True)
        for i in range(18):
            if ta[i]>tb[i]:
                print("Algosia")
                return
            if ta[i]<tb[i]:
                print("Bajtek")
                return
    print("remis")

solve()