#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, w, h, g[N], lis1[N], c1, lis2[N], c2, body[N];
struct ray {
  bool ver;
  int p, t;
  pair<int, int> direct() {
    if (ver)
      return pair<int, int>(p, h);
    else
      return pair<int, int>(w, p);
  }
} a[N];
list<int> que[N];
pair<int, int> ans[N];
void enter() {
  cin >> n >> w >> h;
  for (int i = 0, g; i < n; ++i) {
    cin >> g >> a[i].p >> a[i].t;
    a[i].ver = g == 1;
  }
}
inline bool comp1_s(int x, int y) {
  return g[x] < g[y] || (g[x] == g[y] && a[x].p < a[y].p);
}
inline bool comp1(int x, int y) { return g[x] < g[y]; }
inline bool comp2(int x, int y) { return a[x].p < a[y].p; }
void init() {
  for (int i = 0; i < n; ++i)
    if (!a[i].ver) {
      lis1[c1++] = i;
      g[i] = a[i].t - a[i].p;
    } else
      lis2[c2++] = i;
  sort(lis1, lis1 + c1, comp1_s);
  sort(lis2, lis2 + c2, comp2);
  for (int i = 0; i < n; ++i) body[i] = i;
  for (int i = 0, j; i < c1; i = j + 1) {
    for (j = i; j + 1 < c1 && g[lis1[j + 1]] == g[lis1[i]]; ++j)
      ;
    for (int k = i; k <= j; ++k) que[i].push_back(lis1[k]);
  }
}
void reinit() {
  for (int i = 0, j; i < c1; i = j + 1) {
    for (j = i; j + 1 < c1 && g[lis1[j + 1]] == g[lis1[i]]; ++j)
      ;
    for (int k = i; k <= j; ++k) {
      body[lis1[k]] = que[i].front();
      que[i].pop_front();
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  enter();
  init();
  for (int i = 0; i < c2; ++i) {
    int x = lis2[i];
    g[x] = a[x].t - a[x].p;
    int j = lower_bound(lis1, lis1 + c1, x, comp1) - lis1;
    if (j >= c1 || g[lis1[j]] != g[x]) continue;
    body[x] = que[j].back();
    que[j].pop_back();
    que[j].push_front(x);
  }
  reinit();
  for (int i = 0; i < n; ++i) ans[body[i]] = a[i].direct();
  for (int i = 0; i < n; ++i)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
}
