#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int NCARDS = 8;   const int NVALS = 5;   const int NSTATE = 495;   vector<vector<int> > states;   map<vector<int>, int> mp;   void genstates(vector<int> &v, int at, int rem) {     if (at >= ((int)(v).size())) {       if (rem == 0) {         int id = ((int)(states).size());         states.push_back(v);         mp[v] = id;       }       return;     }     for (v[at] = 0; v[at] <= rem; ++v[at]) genstates(v, at + 1, rem - v[at]);   }   int nxt[NSTATE][NVALS][NVALS];   vector<int> adj[NSTATE][NSTATE];   vector<int> radj[NSTATE][NSTATE];   int deg[NSTATE][NSTATE];   int dp[NSTATE][NSTATE];   int q[NSTATE * NSTATE], qhead, qtail;   void precalc() {     states.clear();     mp.clear();     vector<int> state(NVALS, 0);     genstates(state, 0, NCARDS);     for (int i = (0); i < (((int)(states).size())); ++i)       for (int a = (0); a < (NVALS); ++a)         for (int b = (0); b < (NVALS); ++b) {           if (states[i][a] == 0) {             nxt[i][a][b] = -1;             continue;           }           vector<int> tmp = states[i];           tmp[a]--;           tmp[b]++;           assert(mp.count(tmp));           nxt[i][a][b] = mp[tmp];         }     for (int i = (0); i < (((int)(states).size())); ++i)       for (int j = (0); j < (((int)(states).size())); ++j) {         for (int a = (0); a < (NVALS); ++a)           for (int b = (0); b < (NVALS); ++b)             if (a * b != 0 && states[i][a] != 0 && states[j][b] != 0) {               int c = (a + b) % NVALS;               int ni = j, nj = nxt[i][a][c];               assert(nj != -1);               adj[i][j].push_back(ni * NSTATE + nj);             }         sort(adj[i][j].begin(), adj[i][j].end());         adj[i][j].erase(unique(adj[i][j].begin(), adj[i][j].end()),                         adj[i][j].end());         for (int k = (0); k < (((int)(adj[i][j]).size())); ++k) {           int ii = adj[i][j][k] / NSTATE, jj = adj[i][j][k] % NSTATE;           radj[ii][jj].push_back(i * NSTATE + j);         }       }     int winid = ((int)(states).size()) - 1;     for (int i = (0); i < (((int)(states).size())); ++i)       for (int j = (0); j < (((int)(states).size())); ++j)         dp[i][j] = 0, deg[i][j] = ((int)(adj[i][j]).size());     qhead = qtail = 0;     for (int i = (0); i < (((int)(states).size())); ++i)       dp[i][winid] = -1, q[qhead++] = i * NSTATE + winid;     while (qtail < qhead) {       int i = q[qtail] / NSTATE, j = q[qtail] % NSTATE;       ++qtail;       for (int k = (0); k < (((int)(radj[i][j]).size())); ++k) {         int ii = radj[i][j][k] / NSTATE, jj = radj[i][j][k] % NSTATE;         if (dp[ii][jj] != 0) continue;         if (dp[i][j] == -1) {           dp[ii][jj] = 1;           q[qhead++] = ii * NSTATE + jj;           continue;         }         if (--deg[ii][jj] == 0) {           dp[ii][jj] = -1;           q[qhead++] = ii * NSTATE + jj;           continue;         }       }     }   }   int fst;   int a[NCARDS], b[NCARDS];   void run() {     int nq;     scanf( %d , &nq);     for (int qi = (0); qi < (nq); ++qi) {       scanf( %d , &fst);       for (int i = (0); i < (NCARDS); ++i) scanf( %d , &a[i]);       for (int i = (0); i < (NCARDS); ++i) scanf( %d , &b[i]);       vector<int> acnt(NVALS, 0), bcnt(NVALS, 0);       for (int i = (0); i < (NCARDS); ++i) acnt[a[i]]++, bcnt[b[i]]++;       assert(mp.count(acnt) && mp.count(bcnt));       int aid = mp[acnt], bid = mp[bcnt];       int ans = fst == 0 ? dp[aid][bid] : -dp[bid][aid];       printf( %s n , ans > 0 ?  Alice  : ans < 0 ?  Bob  :  Deal );     }   }   int main() {     precalc();     run();     return 0;   }