#include <bits/stdc++.h>
using namespace std;
struct node {
  int id, g, p, t;
  bool operator<(const node &rhs) const { return p - t < rhs.p - rhs.t; }
  void read(int id_) {
    scanf("%d%d%d", &g, &p, &t);
    id = id_;
  }
} per[(100000 + 5)], g1[(100000 + 5)], g2[(100000 + 5)];
bool cmp(node a, node b) { return a.p < b.p; }
int n1, n2, ax[(100000 + 5)], ay[(100000 + 5)], tx[(100000 + 5)],
    ty[(100000 + 5)];
int main() {
  int n, w, h;
  scanf("%d%d%d", &n, &w, &h);
  for (int i = (1); i <= (int)(n); ++i) per[i].read(i);
  sort(per + 1, per + n + 1);
  int p = 1, npt, tn;
  while (p <= n) {
    n1 = 0, n2 = 0;
    npt = per[p].p - per[p].t;
    while (p <= n && per[p].p - per[p].t == npt) {
      if (per[p].g == 1)
        g1[++n1] = per[p];
      else
        g2[++n2] = per[p];
      ++p;
    }
    if (!n1) {
      for (int i = (1); i <= (int)(n2); ++i)
        ax[g2[i].id] = w, ay[g2[i].id] = g2[i].p;
      continue;
    }
    if (!n2) {
      for (int i = (1); i <= (int)(n1); ++i)
        ax[g1[i].id] = g1[i].p, ay[g1[i].id] = h;
      continue;
    }
    tn = 0;
    sort(g1 + 1, g1 + n1 + 1, cmp);
    sort(g2 + 1, g2 + n2 + 1, cmp);
    for (int i = (1); i <= (int)(n2); ++i) ++tn, tx[tn] = w, ty[tn] = g2[i].p;
    for (int i = (n1); i >= (int)(1); --i) ++tn, tx[tn] = g1[i].p, ty[tn] = h;
    tn = 0;
    for (int i = (n1); i >= (int)(1); --i)
      ++tn, ax[g1[i].id] = tx[tn], ay[g1[i].id] = ty[tn];
    for (int i = (1); i <= (int)(n2); ++i)
      ++tn, ax[g2[i].id] = tx[tn], ay[g2[i].id] = ty[tn];
  }
  for (int i = (1); i <= (int)(n); ++i) printf("%d %d\n", ax[i], ay[i]);
  return 0;
}
