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
// Mateusz Lambert
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <climits>
#include <algorithm>
#define ll long long
#define int128 __uint128_t
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define si set <int>
#define sl set <ll>
#define mins(x) *x.begin()
#define maxs(x) *x.rbegin()
#define vii vector <pair<int, int>>
#define vl vector <ll>
#define vll vector<pair<ll, ll>>
#define vb vector <bool>
#define vs vector <string>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sec second
#define fir first
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	vi a(18), b(18);
	for (int &x : a) cin >> x;
	for (int &x : b) cin >> x;
	sort(all(a), greater<int>());
	sort(all(b), greater<int>());
	int s1=0, s2=0;
	for (int x : a) s1 += x;
	for (int x : b) s2 += x;
	if (s1==s2){
		int k = 0;
		while (k<18 && a[k]==b[k]) k++;
		if (k==18) cout << "remis\n";
		else if (a[k]>b[k]) cout << "Algosia\n";
		else cout << "Bajtek\n";
	} else{
		if (s1>s2) cout << "Algosia\n";
		else cout << "Bajtek\n";
	}
}