#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int sum[maxn], g[maxn], p[maxn], t[maxn], ans[maxn][2];
vector<int> type[maxn << 1];
struct node {
  int x, y, id;
};
struct node tmpans[maxn];
struct node tmpst[maxn];
bool cmp(node t1, node t2) { return t1.y == t2.y ? t1.x > t2.x : t1.y < t2.y; }
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') flag = -1, ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * flag;
}
int main() {
  int i, j, k, m, n, w, h;
  n = read();
  w = read();
  h = read();
  for (i = 1; i <= n; i++) {
    g[i] = read();
    p[i] = read();
    t[i] = read();
    type[p[i] - t[i] + maxn].push_back(i);
  }
  int tmp = (maxn << 1) - 5;
  for (i = 1; i <= tmp; i++) {
    for (j = 0; j < (int)type[i].size(); j++) {
      if (g[type[i][j]] == 1)
        tmpans[j].x = h, tmpans[j].y = p[type[i][j]], tmpst[j].x = 0,
        tmpst[j].y = p[type[i][j]], tmpst[j].id = type[i][j];
      else
        tmpans[j].x = p[type[i][j]], tmpans[j].y = w,
        tmpst[j].x = p[type[i][j]], tmpst[j].y = 0, tmpst[j].id = type[i][j];
    }
    sort(tmpans, tmpans + type[i].size(), cmp);
    sort(tmpst, tmpst + type[i].size(), cmp);
    for (j = 0; j < (int)type[i].size(); j++) {
      ans[tmpst[j].id][0] = tmpans[j].x;
      ans[tmpst[j].id][1] = tmpans[j].y;
    }
  }
  for (i = 1; i <= n; i++) printf("%d %d\n", ans[i][1], ans[i][0]);
  return 0;
}
