#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
struct dancer {
  int type;
  int t;
  int x;
  int num;
  dancer(int type = 0, int t = 0, int x = 0, int num = 0)
      : type(type), t(t), x(x), num(num) {}
};
deque<int> deqs[MAXN * 2];
vector<int> ansy[MAXN * 2];
vector<pair<int, int> > ans;
vector<dancer> d;
vector<int> types;
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  ans.resize(n);
  types.resize(n);
  for (int i = 0; i < n; ++i) {
    int g, p, t;
    cin >> g >> p >> t;
    d.push_back(dancer(g, t, p, i));
  }
  sort(d.begin(), d.end(), [](dancer a, dancer b) { return a.x < b.x; });
  for (int i = 0; i < d.size(); ++i) {
    types[i] = d[i].type;
    if (d[i].type == 1) {
      continue;
    }
    deqs[d[i].t - d[i].x + MAXN].push_back(i);
    ansy[d[i].t - d[i].x + MAXN].push_back(d[i].x);
  }
  for (int i = 0; i < d.size(); ++i) {
    if (types[i] == 2) {
      continue;
    }
    if (deqs[d[i].t - d[i].x + MAXN].empty()) {
      continue;
    }
    int x = d[i].x;
    d[i].type = 2;
    d[i].x = ansy[d[i].t - d[i].x + MAXN][0];
    deqs[d[i].t - x + MAXN].push_front(i);
    int j = deqs[d[i].t - x + MAXN].back();
    deqs[d[i].t - x + MAXN].pop_back();
    d[j].type = 1;
    d[j].x = x;
  }
  for (int i = 0; i < d.size(); ++i) {
    if (d[i].type == 1) {
      ans[d[i].num] = {d[i].x, h};
    }
  }
  for (int i = 0; i < MAXN * 2; ++i) {
    int id = 0;
    while (!deqs[i].empty()) {
      int num = deqs[i].front();
      deqs[i].pop_front();
      ans[d[num].num] = {w, ansy[i][id]};
      ++id;
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
