#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 10;
pair<int, pair<int, pair<int, int> > > z[MAXN];
int g[MAXN], p[MAXN], t[MAXN], ans[MAXN];
map<int, vector<int> > collide;
int main() {
  ios::sync_with_stdio(false);
  int k, w, h;
  cin >> k >> w >> h;
  for (int i = 0; i < k; i++) {
    cin >> z[i].first >> z[i].second.first >> z[i].second.second.first;
    z[i].second.second.second = i;
  }
  sort(z, z + k);
  for (int i = 0; i < k; i++) {
    int idx = z[i].second.second.second;
    g[idx] = z[i].first;
    p[idx] = z[i].second.first;
    t[idx] = z[i].second.second.first;
    t[idx] = -t[idx];
    int d = p[idx] + t[idx];
    collide[d].push_back(idx);
  }
  for (__typeof((collide).begin()) d = (collide).begin(); d != (collide).end();
       d++) {
    vector<int> tot = d->second;
    vector<int> a, b;
    for (int i = 0; i < ((int)(tot).size()); i++) {
      if (g[tot[i]] == 1)
        a.push_back(tot[i]);
      else
        b.push_back(tot[i]);
    }
    int n = ((int)(a).size()), m = ((int)(b).size());
    for (int i = 0; i < min(n, m); i++) {
      ans[b[m - i - 1]] = a[i];
      ans[a[n - i - 1]] = b[i];
    }
    if (m > n) {
      for (int i = n; i < m; i++) ans[b[i - n]] = b[i];
    }
    if (n > m) {
      for (int i = m; i < n; i++) ans[a[i - m]] = a[i];
    }
  }
  for (int i = 0; i < k; i++) {
    if (g[ans[i]] == 1) {
      cout << p[ans[i]] << ' ' << h << endl;
    } else {
      cout << w << ' ' << p[ans[i]] << endl;
    }
  }
  return 0;
}
