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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>

using namespace std;

#ifdef D
#define DEBUG(x)        \
    do {                \
        x               \
        cout.flush();   \
    } while (0)
#else
#define DEBUG(x)
#endif

using ll = long long;
using pii = pair<int, int>;

const int NMAX = 1e6 + 7;

int zzz, n, k;

class Score {
public:
    int sum;
    int tasks[11];

    bool operator==(const Score &rhs) const {
        if (sum != rhs.sum) return false;

        for (int i = 0; i < 11; ++i) {
            if (tasks[i] != rhs.tasks[i]) return false;
        }

        return true;
    }

    bool operator<(const Score &rhs) const {
        if (sum < rhs.sum) return true;
        if (rhs.sum < sum) return false;

        for (int i = 10; i >= 0; --i) {
            if (tasks[i] < rhs.tasks[i]) return true;
            if (rhs.tasks[i] < tasks[i]) return false;
        }

        return false;
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    Score a{}, b{};

    for (int i = 0; i < 18; ++i) {
        cin >> k;
        a.sum += k;
        a.tasks[k]++;
    }

    for (int i = 0; i < 18; ++i) {
        cin >> k;
        b.sum += k;
        b.tasks[k]++;
    }

    if (a == b) {
        cout << "remis\n";
    } else if (a < b) {
        cout << "Bajtek\n";
    } else {
        cout << "Algosia\n";
    }

    return 0;
}