#include <bits/stdc++.h>
using namespace std;
class tancor {
 public:
  int startTime;
  int nomer;
  int oldNomer;
  int startX;
  int startY;
  int defX;
  int defY;
  int value;
};
class bump {
 public:
  int time;
  int index1;
  int index2;
};
bool UDgreater(bump a, bump b) { return a.time < b.time; }
bool UDgreaterNomer(tancor a, tancor b) { return a.nomer < b.nomer; }
bool UDgreaterValue(tancor a, tancor b) {
  if (a.value != b.value) return a.value < b.value;
  if (a.defX != b.defX) return a.defX < b.defX;
  if (a.defX == 0) return a.startX < b.startX;
  return a.startY > b.startY;
}
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<tancor> ts(n);
  vector<int> newIndex(n);
  for (int i = 0; i < n; i++) {
    ts[i] = *new tancor();
    int g, p;
    cin >> g >> p >> ts[i].startTime;
    if (g == 1) {
      ts[i].startX = p;
      ts[i].startY = 0;
      ts[i].defX = 0;
      ts[i].defY = 1;
    } else {
      ts[i].startX = 0;
      ts[i].startY = p;
      ts[i].defX = 1;
      ts[i].defY = 0;
    }
    ts[i].nomer = i;
    ts[i].oldNomer = i;
    newIndex[i] = i;
    if (ts[i].defX == 1)
      ts[i].value = ts[i].startTime - ts[i].startY;
    else
      ts[i].value = ts[i].startTime - ts[i].startX;
  }
  std::sort(ts.begin(), ts.end(), UDgreaterValue);
  for (int p = 0; p < n;) {
    int l = p, m = p + 1;
    while (m < n && ts[l].value == ts[m].value && ts[l].defX == ts[m].defX) m++;
    int r = m;
    while (r < n && ts[l].value == ts[r].value) r++;
    if (r == m) m = l;
    for (int i = l; i < r; i++) {
      ts[i].nomer = ts[m].oldNomer;
      m++;
      if (m == r) m = l;
    }
    p = r;
  }
  std::sort(ts.begin(), ts.end(), UDgreaterNomer);
  for (int i = 0; i < n; i++) {
    if (ts[i].defX == 1) {
      cout << w << " " << ts[i].startY << endl;
    } else {
      cout << ts[i].startX << " " << h << endl;
    }
  }
  return 0;
}
