#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7, tot = 3 * maxn, disp = 1e5 + 1;
vector<pair<int, int> > mv[tot], mh[tot];
int ans[maxn], polarity[maxn], n, w, h, g, p, t;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> w >> h;
  for (int i = 1; i <= n; i++) {
    cin >> g >> p >> t;
    if (g == 1)
      mv[t - p + disp].push_back({p, i});
    else
      mh[t - p + disp].push_back({p, i});
  }
  for (int i = 0; i < tot; i++) {
    if (mv[i].size() == 0) continue;
    if (mh[i].size() == 0) {
      for (auto u : mv[i]) {
        ans[u.second] = u.first;
        polarity[u.second] = 1;
      }
    } else {
      sort(mv[i].rbegin(), mv[i].rend());
      sort(mh[i].begin(), mh[i].end());
      int ptr = 0;
      for (int j = 0; j < mv[i].size(); j++) {
        if (j >= mh[i].size()) {
          ans[mv[i][j].second] = mv[i][ptr++].first;
          polarity[mv[i][j].second] = 1;
        } else {
          polarity[mv[i][j].second] = 2;
          ans[mv[i][j].second] = mh[i][j].first;
        }
      }
    }
  }
  for (int i = 0; i < tot; i++) {
    if (mh[i].size() == 0) continue;
    if (mv[i].size() == 0) {
      for (auto u : mh[i]) {
        ans[u.second] = u.first;
        polarity[u.second] = 2;
      }
    } else {
      sort(mh[i].rbegin(), mh[i].rend());
      sort(mv[i].begin(), mv[i].end());
      int ptr = 0;
      for (int j = 0; j < mh[i].size(); j++) {
        if (j >= mv[i].size()) {
          ans[mh[i][j].second] = mh[i][ptr++].first;
          polarity[mh[i][j].second] = 2;
        } else {
          polarity[mh[i][j].second] = 1;
          ans[mh[i][j].second] = mv[i][j].first;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (polarity[i] == 1)
      cout << ans[i] << " " << h << '\n';
    else
      cout << w << " " << ans[i] << '\n';
  }
  return 0;
}
