#include <bits/stdc++.h>
using namespace std;
queue<int> q[200005], qs[200005];
int ans[100005][2];
int cnt1 = 0, cnt2 = 0, n, h, w;
struct node {
  int pos, t, id;
} a[100005], b[100005];
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
inline bool cmp(node a, node b) { return a.pos < b.pos; }
int main() {
  int i, g;
  n = read();
  w = read();
  h = read();
  for (i = 1; i <= n; i++) {
    g = read();
    if (g == 1) {
      a[++cnt1].pos = read();
      a[cnt1].t = read();
      a[cnt1].id = i;
    }
    if (g == 2) {
      b[++cnt2].pos = read();
      b[cnt2].t = read();
      b[cnt2].id = i;
    }
  }
  sort(a + 1, a + cnt1 + 1, cmp);
  sort(b + 1, b + cnt2 + 1, cmp);
  for (i = cnt2; i >= 1; i--) {
    q[b[i].pos - b[i].t + 100000].push(b[i].id);
    qs[b[i].pos - b[i].t + 100000].push(b[i].pos);
  }
  for (i = 1; i <= cnt1; i++) {
    q[a[i].pos - a[i].t + 100000].push(a[i].id);
    int p = q[a[i].pos - a[i].t + 100000].front();
    q[a[i].pos - a[i].t + 100000].pop();
    ans[p][0] = a[i].pos;
    ans[p][1] = h;
  }
  for (i = 1; i <= 200000; i++) {
    while (!q[i].empty()) {
      int p = q[i].front(), t = qs[i].front();
      q[i].pop();
      qs[i].pop();
      ans[p][0] = w;
      ans[p][1] = t;
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%d %d\n", ans[i][0], ans[i][1]);
  }
  return 0;
}
