#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int q_sz = 1000;
vector<pair<pair<int, int>, int> > a[500000];
vector<pair<pair<int, int>, int> > b[500000];
int x[100100], y[100100];
int main() {
  ios::sync_with_stdio(false);
  cout.flush();
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < (int)(n); ++i) {
    int g, p, t;
    cin >> g >> p >> t;
    if (g == 1) {
      x[i] = p;
      y[i] = h;
    } else {
      x[i] = w;
      y[i] = p;
    }
    a[p - t + 100000].push_back(make_pair(make_pair(g, g == 1 ? -p : p), i));
    b[p - t + 100000].push_back(make_pair(make_pair(-g, g == 1 ? -p : p), i));
  }
  vector<int> ans(n);
  for (int i = 0; i < (int)(500000); ++i) {
    sort(a[i].begin(), a[i].end());
    sort(b[i].begin(), b[i].end());
    for (int j = 0; j < (int)(a[i].size()); ++j) {
      ans[a[i][j].second] = b[i][j].second;
    }
  }
  for (int i = 0; i < (int)(n); ++i) {
    cout << x[ans[i]] << " " << y[ans[i]] << endl;
  }
  return 0;
}
