#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-' ? -1 : f, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
int buf[30];
void write(int x) {
  if (x < 0) putchar('-');
  for (; x; x /= 10) buf[++buf[0]] = x % 10;
  if (!buf[0]) buf[++buf[0]] = 0;
  for (; buf[0]; putchar('0' + buf[buf[0]--]))
    ;
}
const int N = 100005;
struct dancer {
  int g, x, t, id;
  bool operator<(dancer const d) const {
    return t - x < d.t - d.x ||
           t - x == d.t - d.x && (g > d.g || g == d.g && ((x < d.x) ^ (g - 1)));
  }
} srt[N];
int pos[N][2];
int tmp[2][N];
int w, h, n;
int main() {
  n = read(), w = read(), h = read();
  for (int i = 1; i <= n; ++i)
    srt[i].g = read(), srt[i].x = read(), srt[i].t = read(), srt[i].id = i;
  sort(srt + 1, srt + 1 + n);
  int st = 1;
  for (int i = 1; i <= n; ++i) {
    if (i > 1 && srt[i].t - srt[i].x != srt[i - 1].t - srt[i - 1].x) {
      for (int j = st; j < i; ++j)
        if (j - st + 1 > tmp[0][0])
          pos[srt[j].id][0] = w,
          pos[srt[j].id][1] = tmp[1][j - st + 1 - tmp[0][0]];
        else
          pos[srt[j].id][1] = h, pos[srt[j].id][0] = tmp[0][j - st + 1];
      tmp[0][0] = tmp[1][0] = 0;
      st = i;
    }
    if (srt[i].g == 1)
      tmp[0][++tmp[0][0]] = srt[i].x;
    else
      tmp[1][++tmp[1][0]] = srt[i].x;
  }
  for (int j = st; j <= n; ++j)
    if (j - st + 1 > tmp[0][0])
      pos[srt[j].id][0] = w, pos[srt[j].id][1] = tmp[1][j - st + 1 - tmp[0][0]];
    else
      pos[srt[j].id][1] = h, pos[srt[j].id][0] = tmp[0][j - st + 1];
  for (int i = 1; i <= n; ++i)
    write(pos[i][0]), putchar(' '), write(pos[i][1]), putchar('\n');
  return 0;
}
