#include #define int long long using namespace std; const int N=100005; int n,w,h,s[2],mx[N<<2],lz[N<<2]; void pushdown(int u) { mx[u<<1]+=lz[u];mx[u<<1|1]+=lz[u]; lz[u<<1]+=lz[u];lz[u<<1|1]+=lz[u]; lz[u]=0; } void modify(int u,int l,int r,int id) { if(l==r) { if(mx[u]>=h) { mx[u]=-1e18; s[id&1]++; } return; } pushdown(u); int mid=l+r>>1; if(mx[u<<1]>=h)modify(u<<1,l,mid,id); if(mx[u<<1|1]>=h)modify(u<<1|1,mid+1,r,id); mx[u]=max(mx[u<<1],mx[u<<1|1]); } void update(int u,int l,int r,int L,int R,int w,int id) { if(rR)return; if(L<=l&&r<=R) { mx[u]+=w;lz[u]+=w; if(mx[u]>=h)modify(u,l,r,id); return; } pushdown(u); int mid=l+r>>1; update(u<<1,l,mid,L,R,w,id); update(u<<1|1,mid+1,r,L,R,w,id); mx[u]=max(mx[u<<1],mx[u<<1|1]); } signed main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>n>>w>>h; for(int i=1,a,b,x;i<=n;i++) { cin>>a>>b>>x; update(1,1,w,x,x+a-1,b,i); } if(s[1]>s[0])cout<<"A\n"; if(s[0]>s[1])cout<<"B\n"; if(s[0]==s[1])cout<<"DRAW\n"; }