#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 9;
int N, w, h, p[maxn], g[maxn], Id[maxn], t[maxn];
pair<int, int> ans[maxn];
int main() {
  cin >> N >> w >> h;
  for (int i = 0; i < N; i++) {
    scanf("%d%d%d", g + i, p + i, t + i);
    Id[i] = i;
  }
  sort(Id, Id + N,
       [](const int &l, const int &r) { return p[l] - t[l] < p[r] - t[r]; });
  for (int L = 0, R = 0; L < N; L = R + 1) {
    for (; R + 1 < N && p[Id[L]] - t[Id[L]] == p[Id[R + 1]] - t[Id[R + 1]]; R++)
      ;
    vector<int> x, y;
    for (int i = L; i <= R; i++) {
      g[Id[i]] == 1 ? x.push_back(Id[i]) : y.push_back(Id[i]);
    }
    int xsz = x.size(), ysz = y.size();
    sort(x.begin(), x.end(),
         [](const int &l, const int &r) { return p[l] < p[r]; });
    sort(y.begin(), y.end(),
         [](const int &l, const int &r) { return p[l] > p[r]; });
    for (int i = 0; i < ysz; i++) {
      x.push_back(y[i]);
    }
    for (int i = 0; i < xsz; i++) {
      y.push_back(x[i]);
    }
    for (int i = 0; i < xsz + ysz; i++) {
      ans[y[i]].first = (g[x[i]] == 1 ? p[x[i]] : w);
      ans[y[i]].second = (g[x[i]] == 1 ? h : p[x[i]]);
    }
  }
  for (int i = 0; i < N; i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
