#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, w, h;
struct Node {
  int g, p, t, _id;
  bool operator<(const Node &n) const { return p < n.p; }
} a[maxn];
map<int, deque<int> > mp;
int idx[maxn], ax[maxn], ay[maxn];
void doit(int g1, int g2) {
  mp.clear();
  for (int i = 1; i <= n; i++)
    if (a[i].g == g1) mp[a[i].p - a[i].t].push_back(i);
  for (int i = 1; i <= n; i++) {
    if (a[i].g == g2) {
      map<int, deque<int> >::iterator tmp = mp.find(a[i].p - a[i].t);
      if (tmp == mp.end() || tmp->second.empty())
        idx[i] = i;
      else {
        idx[i] = tmp->second.back();
        tmp->second.pop_back();
        tmp->second.push_front(i);
      }
    }
  }
}
void solve() {
  memset(idx, 0, sizeof(idx));
  sort(a + 1, a + 1 + n);
  doit(1, 2);
  doit(2, 1);
  for (int i = 1; i <= n; i++) {
    if (a[i].g == 1) {
      ax[a[idx[i]]._id] = a[i].p;
      ay[a[idx[i]]._id] = h;
    } else {
      ax[a[idx[i]]._id] = w;
      ay[a[idx[i]]._id] = a[i].p;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", ax[i], ay[i]);
}
int main() {
  while (~scanf("%d%d%d", &n, &w, &h)) {
    for (int i = 1; i <= n; i++)
      scanf("%d%d%d", &a[i].g, &a[i].p, &a[i].t), a[i]._id = i;
    solve();
  }
  return 0;
}
