#include <bits/stdc++.h>
using namespace std;
inline 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 * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct dcer {
  int st, gp, p, id, tps;
} G[100000];
int n, w, h, t[200000];
inline bool cmp(const dcer a, const dcer b) {
  if (a.st != b.st) return a.st < b.st;
  if (a.gp != b.gp) return a.gp > b.gp;
  if (a.gp == 2) return a.p > b.p;
  if (a.gp == 1) return a.p < b.p;
}
inline bool cmpp(const dcer a, const dcer b) { return a.tps < b.tps; }
int main() {
  n = read();
  w = read();
  h = read();
  for (int i = 1; i <= n; i++) {
    G[i].gp = read(), G[i].p = read();
    G[i].st = G[i].p - read();
    G[i].id = i;
  }
  sort(G + 1, G + 1 + n, cmp);
  for (int i = 1, j; i <= n; i++) {
    j = i;
    while (G[j + 1].st == G[i].st && j + 1 <= n) j++;
    t[0] = 0;
    for (int k = i; k <= j; k++) t[++t[0]] = G[k].id;
    int tj = i;
    while (G[tj].gp == 2 && tj <= j) tj++;
    int nw = 1;
    for (int k = tj; k <= j; k++) G[k].tps = t[nw++];
    for (int k = i; k < tj; k++) G[k].tps = t[nw++];
    i = j;
  }
  sort(G + 1, G + 1 + n, cmpp);
  for (int i = 1; i <= n; i++) {
    if (G[i].gp == 1) printf("%d %d\n", G[i].p, h);
    if (G[i].gp == 2) printf("%d %d\n", w, G[i].p);
  }
  return 0;
}
