#include #define int long long using namespace std; const int W = 1e5 + 5; int n, w, h, score[2], b[4 * W], tree[4 * W]; void push_down(int x) { if (b[x]) { tree[x * 2] += b[x], tree[x * 2 + 1] += b[x]; b[x * 2] += b[x], b[x * 2 + 1] += b[x]; b[x] = 0; } } void get(int l, int r, int x, int id) { if (tree[x] < h) return; if (l == r) { tree[x] = -1e18; score[id]++; return; } push_down(x); int mid = (l + r) / 2; if (tree[x * 2] >= h) get(l, mid, x * 2, id); if (tree[x * 2 + 1] >= h) get(mid + 1, r, x * 2 + 1, id); tree[x] = max(tree[2 * x], tree[2 * x + 1]); } void update(int l, int r, int s, int t, int k, int x, int id) { if (l <= s && t <= r) { tree[x] += k, b[x] += k; if (tree[x] >= h) get(s, t, x, id); return; } push_down(x); int mid = (s + t) / 2; if (l <= mid) update(l, r, s, mid, k, x * 2, id); if (r > mid) update(l, r, mid + 1, t, k, x * 2 + 1, id); tree[x] = max(tree[2 * x], tree[2 * x + 1]); } signed main() { //freopen ("game.in", "r", stdin); //freopen ("game.out", "w", stdout); scanf("%lld%lld%lld", &n, &w, &h); for (int i = 1; i <= n; i++) { int a, b, x; scanf("%lld%lld%lld", &a, &b, &x); if (score[0] + score[1] == w) break; update(x, a + x - 1, 1, w, b, 1, i % 2); } if (score[1] > score[0]) printf("A"); else if (score[1] < score[0]) printf("B"); else printf("DRAW"); return 0; }