#include <bits/stdc++.h>
using namespace std;
int g[100005];
int p[100005];
int t[100005];
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    cin >> g[i] >> p[i] >> t[i];
  }
  map<int, pair<vector<int>, vector<int> > > M;
  for (int i = 0; i < n; i++) {
    ((g[i] == 1) ? M[t[i] - p[i]].first : M[t[i] - p[i]].second)
        .push_back(p[i]);
  }
  for (map<int, pair<vector<int>, vector<int> > >::iterator it = M.begin();
       it != M.end(); it++) {
    vector<int>& vx = (it->second).first;
    vector<int>& vy = (it->second).second;
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
  }
  for (int i = 0; i < n; i++) {
    vector<int>& vx = (M[t[i] - p[i]]).first;
    vector<int>& vy = (M[t[i] - p[i]]).second;
    if (g[i] == 1) {
      int pos = distance(vx.begin(), lower_bound(vx.begin(), vx.end(), p[i]));
      if (vx.size() - pos > vy.size()) {
        cout << vx[vy.size() + pos] << " " << h << endl;
      } else {
        cout << w << " " << vy[vx.size() - pos - 1] << endl;
      }
    } else {
      int pos = distance(vy.begin(), lower_bound(vy.begin(), vy.end(), p[i]));
      if (vy.size() - pos > vx.size()) {
        cout << w << " " << vy[vx.size() + pos] << endl;
      } else {
        cout << vx[vy.size() - pos - 1] << " " << h << endl;
      }
    }
  }
  return 0;
}
