#include <bits/stdc++.h>
using namespace std;
int cnt = 0;
int SM[100000];
int ans[500][500][2], FC[500][500][2], H[5];
vector<int> Q[500];
int dfs(int a, int b) {
  int sum = 0;
  bool A = false, B = false;
  for (int i = 0; i < 5; i++) {
    if (Q[a][i] > 0) {
      for (int j = 0; j < 5; j++)
        if (Q[b][j] > 0 && i * j != 0) {
          sum++;
        }
    }
  }
  return sum;
}
struct T {
  int a, b, c;
};
queue<T> G;
int main() {
  int sum = 0, k, g = 10000;
  for (int i = 0; i < 5; i++) H[i] = g, g /= 10;
  for (int i = 0; i < 500; i++)
    for (int j = 0; j < 5; j++) Q[i].push_back(0);
  for (int i = 1; i < 100000; i++) {
    int u = 0, p = i + 100000, r = 4;
    while (p > 1) u += p % 10, Q[cnt][r--] = p % 10, p /= 10;
    if (u == 8) {
      SM[i] = cnt;
      sum++, cnt++;
    }
  }
  for (int i = 0; i < cnt; i++)
    for (int j = 0; j < cnt; j++) FC[i][j][0] = FC[i][j][1] = dfs(i, j);
  for (int i = 0; i < cnt; i++)
    for (int j = 0; j < cnt; j++)
      for (int k = 0; k < 2; k++) {
        if (i == cnt - 1)
          ans[i][j][k] = 1;
        else if (j == cnt - 1)
          ans[i][j][k] = 2;
        else
          continue;
        G.push({i, j, k});
      }
  while (!G.empty()) {
    T p = G.front();
    G.pop();
    int a = p.a, b = p.b, c = p.c;
    for (int i = 0; i < 5; i++)
      if (Q[a][i] > 0)
        for (int j = 0; j < 5; j++)
          if (Q[b][j] > 0) {
            int q = (c == 0 ? b : a), res = 0, l = 10000, f;
            for (int k = 0; k < 5; k++) res += l * Q[q][k], l /= 10;
            if (c == 0) {
              f = (j - i + 5) % 5;
              if (i == 0 || f == 0) continue;
              res -= H[j];
              res += H[f];
              if (ans[a][b][c] == 2) {
                int& U = ans[a][SM[res]][!c];
                if (U == 0) G.push({a, SM[res], !c});
                U = 2;
              } else {
                if (--FC[a][SM[res]][!c] == 0) {
                  ans[a][SM[res]][!c] = 1;
                  G.push({a, SM[res], !c});
                }
              }
            } else {
              f = (i - j + 5) % 5;
              if (j == 0 || f == 0) continue;
              res -= H[i];
              res += H[f];
              if (ans[a][b][c] == 1) {
                int& U = ans[SM[res]][b][!c];
                if (U == 0) G.push({SM[res], b, !c});
                U = 1;
              } else {
                if (--FC[SM[res]][b][!c] == 0) {
                  ans[SM[res]][b][!c] = 2;
                  G.push({SM[res], b, !c});
                }
              }
            }
          }
  }
  int t;
  scanf("%d", &t);
  while (t--) {
    int x, h;
    scanf("%d", &x);
    int W[5] = {}, g = 10000, a = 0, b = 0;
    for (int i = 0; i < 8; i++) scanf("%d", &h), W[h]++;
    for (int i = 0; i < 5; i++) a += g * W[i], g /= 10;
    g = 10000;
    int W1[5] = {};
    for (int i = 0; i < 8; i++) scanf("%d", &h), W1[h]++;
    for (int i = 0; i < 5; i++) b += g * W1[i], g /= 10;
    int res = ans[SM[a]][SM[b]][x];
    if (res == 0)
      cout << "Deal\n";
    else if (res == 1)
      cout << "Alice\n";
    else if (res == 2)
      cout << "Bob\n";
  }
}
