#include <bits/stdc++.h>
using namespace std;
int n, w, h;
int g, p, t;
pair<int, int> ans[100010];
vector<pair<pair<int, int>, pair<int, int> > > v[200020], vv[200020];
void solve(const vector<pair<pair<int, int>, pair<int, int> > >& v,
           const vector<pair<pair<int, int>, pair<int, int> > >& vv) {
  int k = v.size(), kk = vv.size();
  if (k + kk == 0) return;
  for (int j = 0; j < k; ++j) {
    int p = k - j;
    int q = kk;
    if (p > q) ans[v[j + q].first.second] = v[j].second;
    if (p <= q) ans[vv[p - 1].first.second] = v[j].second;
  }
}
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d %d", &g, &p, &t);
    if (g == 1) {
      v[t - p + 100000].push_back(make_pair(make_pair(-t, i), make_pair(p, h)));
    } else {
      vv[t - p + 100000].push_back(
          make_pair(make_pair(-p, i), make_pair(w, p)));
    }
  }
  for (int i = 0; i <= 200000; ++i) {
    sort(v[i].begin(), v[i].end());
    sort(vv[i].begin(), vv[i].end());
    solve(v[i], vv[i]);
    solve(vv[i], v[i]);
  }
  for (int i = 1; i <= n; ++i) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
