#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, w, h;
bool vis[N];
struct node {
  int op, p, t, res;
} a[N];
map<int, vector<int> > mp;
bool cmp1(int x, int y) {
  if (a[x].op != a[y].op) return a[x].op < a[y].op;
  if (a[x].op == 1)
    return a[x].p > a[y].p;
  else
    return a[x].p < a[y].p;
}
bool cmp2(int x, int y) {
  if (a[x].op != a[y].op) return a[x].op > a[y].op;
  if (a[x].op == 1)
    return a[x].p > a[y].p;
  else
    return a[x].p < a[y].p;
}
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].op, &a[i].p, &a[i].t);
    mp[a[i].p - a[i].t].push_back(i);
    a[i].op = 3 - a[i].op;
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    int tmp = a[i].p - a[i].t, cnt = mp[tmp].size();
    vector<int> cnt1, cnt2;
    cnt1 = cnt2 = mp[tmp];
    sort(cnt1.begin(), cnt1.end(), cmp1);
    sort(cnt2.begin(), cnt2.end(), cmp2);
    for (int j = 0; j < cnt; j++) a[cnt1[j]].res = cnt2[j], vis[cnt1[j]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    node e = a[a[i].res];
    if (e.op == 1)
      printf("%d %d\n", w, e.p);
    else
      printf("%d %d\n", e.p, h);
  }
  return 0;
}
