#include <bits/stdc++.h>
using namespace std;
const int NR = 1e5 + 10;
void Min(int& x, int y) { x = min(x, y); }
void Max(int& x, int y) { x = max(x, y); }
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int n, w, h;
struct Nd {
  int id, x, t, num;
  bool operator<(const Nd& A) const {
    if (id != A.id) return id < A.id;
    if (x - t == A.x - A.t) return t < A.t;
    return x - t < A.x - A.t;
  }
} a[NR], b[NR];
int L[NR], R[NR];
int fid[NR];
int ans1[NR], ans2[NR];
int main() {
  n = read(), w = read(), h = read();
  for (int i = 1; i <= n; i++) {
    a[i].id = read(), a[i].x = read();
    a[i].t = read(), a[i].num = i, b[i] = a[i];
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) fid[i] = a[i].num;
  int fj = 0;
  for (int i = 1; i <= n; i++)
    if (a[i].id == 2) {
      fj = i;
      break;
    }
  for (int i = fj; i <= n; i++) {
    if (!L[1] && a[i].x - a[i].t == a[1].x - a[1].t) L[1] = i;
    if (a[i].x - a[i].t == a[1].x - a[1].t) R[1] = i;
  }
  if (!L[1] && !R[1]) L[1] = fj, R[1] = fj - 1;
  for (int i = 2; i < fj; i++) {
    L[i] = L[i - 1], R[i] = R[i - 1];
    while (R[i] < n && a[R[i] + 1].x - a[R[i] + 1].t <= a[i].x - a[i].t) R[i]++;
    while (L[i] <= R[i] && a[L[i]].x - a[L[i]].t < a[i].x - a[i].t) L[i]++;
  }
  for (int i = 1; i < fj; i++) {
    if (!L[fj] && a[i].x - a[i].t == a[fj].x - a[fj].t) L[fj] = i;
    if (a[i].x - a[i].t == a[fj].x - a[fj].t) R[fj] = i;
  }
  if (!L[fj] && !R[fj]) L[fj]++;
  for (int i = fj + 1; i <= n; i++) {
    L[i] = L[i - 1], R[i] = R[i - 1];
    while (R[i] < fj - 1 && a[R[i] + 1].x - a[R[i] + 1].t <= a[i].x - a[i].t)
      R[i]++;
    while (L[i] <= R[i] && a[L[i]].x - a[L[i]].t < a[i].x - a[i].t) L[i]++;
  }
  for (int i = 1; i <= n; i++) {
    if (R[i] < L[i]) continue;
    int id = a[i].num;
    int tt = -1, j = R[i];
    if (R[i] - L[i] >= i - L[j]) {
      ans1[a[R[i] - (i - L[j])].num] = a[i].x;
      ans2[a[R[i] - (i - L[j])].num] = a[i].id;
    } else {
      ans1[a[i - (R[i] - L[i]) - 1].num] = a[i].x;
      ans2[a[i - (R[i] - L[i]) - 1].num] = a[i].id;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (ans2[i] == 0) ans2[i] = b[i].id, ans1[i] = b[i].x;
    if (ans2[i] == 1) printf("%d %d\n", ans1[i], h);
    if (ans2[i] == 2) printf("%d %d\n", w, ans1[i]);
  }
  return 0;
}
