#include <bits/stdc++.h>
using namespace std;
struct node {
  int num, lab, ran;
  bool operator<(const node &a) const {
    if (num == a.num && ran == a.ran) return lab < a.lab;
    if (num == a.num) return ran > a.ran;
    return num < a.num;
  }
};
set<node> sp;
map<int, int> tp;
int x[100005], y[100005], w, h, cnt, rs[100005], lo[100005], ans[2][100005],
    xx[100005], yy[100005], zz[100005];
bool cmp(int a, int b) {
  if (x[a] == x[b]) return y[a] > y[b];
  return x[a] < x[b];
}
set<node>::iterator it;
int main() {
  int n, i, j;
  scanf("%d%d%d", &n, &w, &h);
  for (i = 1; i <= n; i++) scanf("%d%d%d", &xx[i], &yy[i], &zz[i]);
  for (i = 1; i <= n; i++) {
    int xc, yc, zc;
    xc = xx[i];
    yc = yy[i];
    zc = zz[i];
    if (xc == 2) {
      sp.insert((node){-zc + yc, i, yc});
    } else {
      x[++cnt] = yc;
      y[cnt] = -zc;
      lo[cnt] = i;
      rs[cnt] = cnt;
    }
  }
  sort(rs + 1, rs + 1 + cnt, cmp);
  for (i = 1; i <= cnt; i++) {
    it = sp.lower_bound((node){y[rs[i]] + x[rs[i]], 0, 999999});
    if (it != sp.end()) {
      if ((*it).num != y[rs[i]] + x[rs[i]]) {
        ans[0][lo[rs[i]]] = x[rs[i]];
        ans[1][lo[rs[i]]] = h;
      } else {
        ans[0][(*it).lab] = x[rs[i]];
        ans[1][(*it).lab] = h;
        sp.erase(it);
        sp.insert((node){y[rs[i]] + x[rs[i]], lo[rs[i]],
                         --tp[-(y[rs[i]] + x[rs[i]])]});
      }
    } else {
      ans[0][lo[rs[i]]] = x[rs[i]];
      ans[1][lo[rs[i]]] = h;
    }
  }
  cnt = 0;
  tp.clear();
  sp.clear();
  for (i = 1; i <= n; i++) {
    int xc, yc, zc;
    xc = xx[i];
    yc = yy[i];
    zc = zz[i];
    if (xc == 1) {
      sp.insert((node){-zc + yc, i, yc});
    } else {
      x[++cnt] = yc;
      y[cnt] = -zc;
      lo[cnt] = i;
      rs[cnt] = cnt;
    }
  }
  sort(rs + 1, rs + 1 + cnt, cmp);
  for (i = 1; i <= cnt; i++) {
    it = sp.lower_bound((node){y[rs[i]] + x[rs[i]], 0, 999999});
    if (it != sp.end()) {
      if ((*it).num != y[rs[i]] + x[rs[i]]) {
        ans[0][lo[rs[i]]] = w;
        ans[1][lo[rs[i]]] = x[rs[i]];
      } else {
        ans[0][(*it).lab] = w;
        ans[1][(*it).lab] = x[rs[i]];
        sp.erase(it);
        sp.insert((node){y[rs[i]] + x[rs[i]], lo[rs[i]],
                         --tp[-(y[rs[i]] + x[rs[i]])]});
      }
    } else {
      ans[0][lo[rs[i]]] = w;
      ans[1][lo[rs[i]]] = x[rs[i]];
    }
  }
  for (i = 1; i <= n; i++) printf("%d %d\n", ans[0][i], ans[1][i]);
  return 0;
}
