#include <bits/stdc++.h>
using namespace std;
stringstream output;
inline void eOP();
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  map<int, map<int, int>> data;
  for (int i = 0; i < n; ++i) {
    int g, p, t;
    cin >> g >> p >> t;
    int x, y;
    switch (g) {
      case 1:
        x = p;
        y = -t;
        break;
      case 2:
        x = -t;
        y = p;
        break;
    }
    data[x + y][x] = i;
  }
  int* resultX = new int[n];
  int* resultY = new int[n];
  for (auto git = data.begin(); git != data.end(); ++git) {
    auto pts = git->second;
    vector<int> is;
    vector<int> xs;
    for (auto xit = pts.begin(); xit != pts.end(); ++xit) {
      is.push_back(xit->second);
      if (xit->first > 0) {
        xs.push_back(xit->first);
      }
    }
    for (auto xit = pts.begin(); xit != pts.end(); ++xit) {
      if (xit->first > 0) {
        break;
      }
      xs.push_back(xit->first);
    }
    for (int i = 0; i < is.size(); ++i) {
      int idx = is[i];
      int x = xs[i];
      if (x > 0) {
        resultX[idx] = x;
        resultY[idx] = h;
      } else {
        resultX[idx] = w;
        resultY[idx] = git->first - x;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    output << resultX[i] << " " << resultY[i] << endl;
  }
  eOP();
}
void eOP() {
  cout << output.str();
  output.str(string());
  exit(0);
}
