#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
int n, f;
int res[MAX_N + 1];
int sieve[MAX_N + 1];
vector<unsigned long long> b;
vector<unsigned long long> g[200];
int main() {
  b.clear();
  for (int i = 0; i < 200; ++i) g[i].clear();
  cin >> n >> f;
  for (int i = 2; i <= MAX_N; ++i)
    if (sieve[i] == 0) {
      for (int j = i * 2; j <= MAX_N; j += i) sieve[j] = i;
    }
  for (int i = 0; i <= MAX_N; i += 64) {
    long long t = 0;
    for (int j = 0; j < 64 && i + j <= MAX_N; ++j) {
      if (i + j == 0 || i + j == 1 || i + j == f) continue;
      if (sieve[i + j] == 0 || sieve[(i + j) / sieve[i + j]] == 0)
        t |= 1LL << (64 - j - 1);
    }
    b.push_back(t);
    for (int j = 0; j < 200; ++j) g[j].push_back(0);
  }
  for (int i = 0; i <= MAX_N; ++i) {
    res[i] = 0;
    while (true) {
      bool ok = false;
      int p = i / 64;
      int q = 0;
      int t = i % 64;
      if (g[res[i]][p] & (b[q] >> (64 - t - 1))) {
        ++res[i];
        continue;
      }
      --p;
      while (p >= 0) {
        if (t < 63 && (g[res[i]][p] >> (t + 1)) & b[q]) {
          ++res[i];
          ok = true;
          break;
        }
        ++q;
        if (g[res[i]][p] & (b[q] >> (64 - t - 1))) {
          ++res[i];
          ok = true;
          break;
        }
        --p;
      }
      if (!ok) break;
    }
    g[res[i]][i / 64] |= (1LL << (i % 64));
  }
  int nim = 0;
  for (int i = 0; i < n; ++i) {
    int b, w, r;
    cin >> b >> w >> r;
    int d1 = w - b - 1;
    int d2 = r - w - 1;
    nim ^= res[d1] ^ res[d2];
    cout << res[d1] << " " << res[d2] << endl;
  }
  if (nim != 0)
    cout << "Alice\nBob\n";
  else
    cout << "Bob\nAlice\n";
  return 0;
}
