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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
#define ll long long
#define llu long long unsigned
#define ld long double
#define fr(i,n) for(int i=0;i<n;i++)
#define watch(x) cout<<(#x)<<"=="<<(x)<<endl
#define ft first
#define sc second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define P 1000000007llu
#define N 200005
#define M 1000001
#define LC 262144
using namespace std;

int getchar_pos_int() {
    int n=0, c=getchar();
    while('0'<=c&&c<='9') {n=n*10+c-'0'; c=getchar();}
    return n;
}

int a[18], b[18], aSum=0,bSum=0;

int main() {
    fr(i,18) {
        a[i]=getchar_pos_int();
        aSum+=a[i];
    }
    fr(i,18) {
        b[i]=getchar_pos_int();
        bSum+=b[i];
    }
    if(aSum>bSum) {
        puts("Algosia");
        return 0;
    }
    if(bSum>aSum) {
        puts("Bajtek");
        return 0;
    }
    for(int i=10;i>0;i--) {
        aSum=bSum=0;
        fr(j,18) aSum+=(a[j]==i),bSum+=(b[j]==i);
        if(aSum>bSum) {
            puts("Algosia");
            return 0;
        }
        if(bSum>aSum) {
            puts("Bajtek");
            return 0;
        }
    }
    puts("remis");
    return 0;
}