#include <bits/stdc++.h>
using namespace std;
namespace ioput {
template <typename T>
T read() {
  T x = 0, f = 1;
  char c = getchar_unlocked();
  while ((c < '0') || (c > '9')) {
    if (c == '-') f = -1;
    c = getchar_unlocked();
  }
  while ((c >= '0') && (c <= '9'))
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar_unlocked();
  return x * f;
}
template <typename T>
void write(T x, char c) {
  static char t[20];
  static int tlen;
  t[tlen = 1] = c;
  if (x < 0) putchar_unlocked('-'), x = -x;
  do t[++tlen] = x % 10 + '0', x /= 10;
  while (x);
  while (tlen) putchar_unlocked(t[tlen--]);
}
}  // namespace ioput
using namespace ioput;
const int maxn = 100005;
struct seg {
  int id, pos, t;
  bool operator<(const seg &A) const {
    return pos - t == A.pos - A.t ? pos < A.pos : pos - t < A.pos - A.t;
  }
} a[maxn], b[maxn], tmp[maxn];
int a_cnt, b_cnt;
int p[maxn], n, W, H;
pair<int, int> ans[maxn];
int main() {
  n = read<int>(), W = read<int>(), H = read<int>();
  int type, pos, t;
  for (int i = 1, iend = n; i <= iend; ++i) {
    type = read<int>(), pos = read<int>(), t = read<int>();
    if (type == 1)
      a[++a_cnt] = (seg){i, pos, t};
    else
      b[++b_cnt] = (seg){i, pos, t};
  }
  sort(a + 1, a + 1 + a_cnt);
  sort(b + 1, b + 1 + b_cnt);
  int cur = 1;
  for (int i = 1, iend = a_cnt; i <= iend; ++i) {
    static stack<int> stk;
    int j = i;
    while ((j < a_cnt) && (a[j + 1].pos - a[j + 1].t == a[i].pos - a[i].t)) ++j;
    int pos = j, tmpcur;
    while ((cur <= b_cnt) && (b[cur].pos - b[cur].t < a[i].pos - a[i].t)) ++cur;
    tmpcur = cur;
    for (int k = j, kend = i; k >= kend; --k) stk.push(a[k].id);
    while ((cur <= b_cnt) && (b[cur].pos - b[cur].t == a[i].pos - a[i].t))
      stk.push(b[cur].id), ++cur;
    for (int k = i, kend = j; k <= kend; ++k) a[k].id = stk.top(), stk.pop();
    for (int k = cur - 1, kend = tmpcur; k >= kend; --k)
      b[k].id = stk.top(), stk.pop();
    i = j;
  }
  for (int i = 1, iend = a_cnt; i <= iend; ++i)
    ans[a[i].id] = make_pair(a[i].pos, H);
  for (int i = 1, iend = b_cnt; i <= iend; ++i)
    ans[b[i].id] = make_pair(W, b[i].pos);
  for (int i = 1, iend = n; i <= iend; ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
