#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 2e5 + 100;
const ll mod = 1e9 + 7;
int t, cs;
string board[3];
vector <int> valid;
int dp[1 << 9];
int m(int x) {
return 1 << x;
}
int check(int mask) {
if (~dp[mask]) return dp[mask];
dp[mask] = 0;
for (const int& validMask: valid) {
if ((mask & validMask) == validMask) {
return dp[mask] = 1;
}
}
for (int i = 0; i < 9; i++) {
if (mask & m(i)) continue;
dp[mask] |= !check(mask | m(i));
}
return dp[mask];
}
int main() {
valid.push_back(m(0) | m(1) | m(2));
valid.push_back(m(3) | m(4) | m(5));
valid.push_back(m(6) | m(7) | m(8));
valid.push_back(m(0) | m(3) | m(6));
valid.push_back(m(1) | m(4) | m(7));
valid.push_back(m(2) | m(5) | m(8));
valid.push_back(m(0) | m(4) | m(8));
valid.push_back(m(6) | m(4) | m(2));
memset(dp, -1, sizeof dp);
check(0);
while (cin >> t) {
while (t--) {
int mask = 0;
for (int i = 0; i < 3; i++) {
cin >> board[i];
for (const char &c: board[i]) {
mask <<= 1;
mask |= (c == 'X');
}
}
cout << "Game #" << ++cs << ": " << (!dp[mask] ? "Bob" : "Alice") << "\n";
}
}
return 0;
}