#include <bits/stdc++.h>
using namespace std;
int f[1000010], b[1000010], map1[1000010], fmap[1000010], v2[1000010],
    a[1000010], c[1010][1010], u[1010][1010], v[1010][1010], v1[1010][1010],
    h1[1000010], g1[1000010], g2[1000010], tot;
struct node {
  int x, y, z;
} q[1000010];
int js(int *a) {
  int i;
  for (i = 0; i <= 4; i++) v2[i] = 0;
  for (i = 1; i <= 8; i++) v2[a[i]]++;
  int sum = 0;
  for (i = 0; i <= 4; i++) sum = sum * 10 + v2[i];
  return sum;
}
void fjs(int *a, int sum) {
  int g1 = fmap[sum], i;
  for (i = 4; i >= 0; i--) {
    v2[i] = g1 % 10;
    g1 /= 10;
  }
  int top = 0;
  for (i = 1; i <= 8; i++) {
    while (!v2[top]) top++;
    a[i] = top;
    v2[top]--;
  }
}
void dfs(int x, int y) {
  int i;
  if (x == 9) {
    int sum = js(f);
    map1[sum] = ++tot;
    fmap[tot] = sum;
    return;
  }
  for (i = y; i <= 4; i++) {
    f[x] = i;
    dfs(x + 1, i);
  }
}
void bfs(int x) {
  int r = 0, l = x, i, j, k;
  while (r < l) {
    node xx = q[r];
    r++;
    fjs(g1, xx.x);
    fjs(g2, xx.y);
    for (i = 1; i <= 8; i++) {
      int x = g2[i];
      int g = fmap[xx.y] - h1[g2[i]];
      for (j = 1; j <= 8; j++) {
        int y = g1[j];
        if (y != 0 && y != x) {
          g2[i] = (g2[i] + 5 - g1[j]) % 5;
          int u1 = map1[g + h1[g2[i]]];
          u[u1][xx.x]--;
          if (v1[u1][xx.x])
            c[u1][xx.x] = max(c[u1][xx.x], -xx.z);
          else {
            c[u1][xx.x] = -xx.z;
            v1[u1][xx.x] = 1;
          }
          if (!v[u1][xx.x] && (u[u1][xx.x] == 0 || xx.z == -1)) {
            v[u1][xx.x] = 1;
            q[l].x = u1;
            q[l].y = xx.x;
            q[l].z = c[u1][xx.x];
            l++;
          }
          g2[i] = x;
        }
      }
    }
  }
}
int main() {
  int i, j, k, flag, t, a1, b1;
  scanf("%d", &t);
  dfs(1, 0);
  h1[4] = 1;
  for (i = 3; i >= 0; i--) h1[i] = h1[i + 1] * 10;
  for (i = 1; i <= 8; i++) a[i] = 0;
  int h = map1[js(a)];
  for (i = 1; i <= tot; i++)
    for (j = 1; j <= tot; j++) {
      fjs(g1, i);
      fjs(g2, j);
      for (a1 = 1; a1 <= 8; a1++) {
        if (g1[a1] != 0) {
          for (b1 = 1; b1 <= 8; b1++)
            if (g1[a1] != g2[b1]) {
              int h10 =
                  map1[fmap[j] - h1[g2[b1]] + h1[(g2[b1] - g1[a1] + 5) % 5]];
              u[h10][i]++;
            }
        }
      }
    }
  int l = 0;
  for (i = 1; i <= tot; i++) {
    if (i != h) {
      q[l].x = h;
      q[l].y = i;
      q[l].z = 1;
      l++;
      q[l].x = i;
      q[l].y = h;
      q[l].z = -1;
      l++;
      c[h][i] = 1;
      c[i][h] = -1;
      v[i][h] = 1;
      v[h][i] = 1;
    }
  }
  bfs(l);
  while (t--) {
    scanf("%d", &flag);
    for (i = 1; i <= 8; i++) scanf("%d", &a[i]);
    for (i = 1; i <= 8; i++) scanf("%d", &b[i]);
    int sum1 = map1[js(a)];
    int sum2 = map1[js(b)];
    if (flag == 1) swap(sum1, sum2);
    if (c[sum1][sum2] == 0 || v[sum1][sum2] == 0) {
      printf("Deal\n");
      continue;
    } else if ((c[sum1][sum2] == -1 && flag == 1) ||
               (c[sum1][sum2] == 1 && flag == 0))
      printf("Alice\n");
    else
      printf("Bob\n");
  }
}
