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
#include <cstdio>

void gen() {
	long long x = 1;
	for (int i = 0; i < 9; ++i)
		x *= 19;
	printf("long long magic[] = {0,%lld",x);
	long long y = 1;
	for (int i = 2; i <= 10; ++i) {
		printf(",%lld", x * i + y);
		y *= 19;
	}
	printf("};\n");
}

long long magic[] = { 0,322687697779,645375395559,968063093356,1290750791477,1613438495754,1936126316995,2258816360552,2581548628113,2905083151750,3243860540831};

long long readSingle() {
	long long res = 0;
	for (int i = 0; i < 18; ++i) {
		int s;
		scanf("%d", &s);
		res += magic[s];
	}
	return res;
}

int finish(const char* msg) {
	printf("%s\n", msg);
	return 0;
}

int main() {
	long long a = readSingle();
	long long b = readSingle();

	if (a > b) return finish("Algosia");
	if (a < b) return finish("Bajtek");
	return finish("remis");
}