#include <bits/stdc++.h>
using namespace std;
const int offset = 100000;
vector<vector<int> > group(2 * offset + 10);
struct Point {
  int p, t, g, i;
};
vector<Point> pts;
vector<pair<int, int> > pos;
int main() {
  int N, W, H;
  scanf("%d%d%d", &N, &W, &H);
  pts.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    int g, p, t;
    scanf("%d%d%d", &g, &p, &t);
    group[p - t + offset].push_back(i);
    pts[i] = {p, t, g, i};
  }
  pos.resize(N + 1);
  for (int i = 0; i < group.size(); i++) {
    if (group[i].empty()) continue;
    vector<int> xs, ys;
    for (auto idx : group[i]) {
      if (pts[idx].g == 1) {
        xs.push_back(pts[idx].p);
      } else {
        ys.push_back(pts[idx].p);
      }
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    reverse(ys.begin(), ys.end());
    sort(group[i].begin(), group[i].end(), [&](const int& a, const int& b) {
      if (pts[a].g != pts[b].g) {
        return pts[a].g == 2;
      } else {
        if (pts[a].g == 2) {
          return pts[a].p > pts[b].p;
        } else {
          return pts[a].p < pts[b].p;
        }
      }
    });
    for (int j = 0; j < xs.size(); j++) {
      pos[group[i][j]] = {xs[j], H};
    }
    for (int j = 0; j < ys.size(); j++) {
      pos[group[i][j + xs.size()]] = {W, ys[j]};
    }
  }
  for (int i = 1; i <= N; i++) {
    printf("%d %d\n", pos[i].first, pos[i].second);
  }
  return 0;
}
