#include <bits/stdc++.h>
const int maxn = 100010;
int n, w, h, ans[maxn];
struct pos {
  int x, y;
} Pos[maxn];
struct lr {
  int i, p, t, ty, x;
  bool operator<(const lr &a) const { return ty != a.ty ? ty < a.ty : p < a.p; }
} a[maxn], b[maxn], x[maxn], tmp[maxn];
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; ++i) {
    int ty, tp, tt;
    scanf("%d%d%d", &ty, &tp, &tt);
    x[i] = (lr){i, tp, tt, tt - tp, ty == 1};
    ans[i] = i;
    if (ty == 1)
      Pos[i] = (pos){tp, h};
    else
      Pos[i] = (pos){w, tp};
  }
  std::sort(x + 1, x + 1 + n);
  for (int i = 1; i <= n; ++i) {
    int delta = x[i].ty, cnt1 = 0, cnt2 = 0, cnt = 0;
    while (i <= n && x[i].ty == delta) {
      if (x[i].x)
        a[++cnt1] = x[i];
      else
        b[++cnt2] = x[i];
      ++i;
    }
    for (int j = cnt2; j; --j) tmp[cnt++] = b[j];
    for (int j = 1; j <= cnt1; ++j) tmp[cnt++] = a[j];
    for (int j = 0; j < cnt; ++j) {
      ans[tmp[j].i] = tmp[(j + cnt2) % cnt].i;
    }
    --i;
  }
  for (int i = 1; i <= n; ++i) printf("%d %d\n", Pos[ans[i]].x, Pos[ans[i]].y);
  return ~~(0 ^ 0 ^ 0);
}
