#include <bits/stdc++.h>
template <class t>
void maxi(t &x, t y) {
  if (x < y) x = y;
}
template <class t>
void mini(t &x, t y) {
  if (x > y) x = y;
}
using namespace std;
int n, w, h, g[300005], p[300005], t[300005], d[300005], in[300005];
vector<pair<int, int> > ans(300005);
int func(int i, int j) {
  if (d[i] == d[j]) {
    if (g[i] == g[j]) return p[i] < p[j];
    return g[i] < g[j];
  }
  return d[i] < d[j];
}
int main() {
  ios::sync_with_stdio(0);
  cout << setprecision(10) << fixed;
  cin >> n >> w >> h;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> g[i] >> p[i] >> t[i];
    d[i] = p[i] - t[i], in[i] = i;
  }
  sort(in, in + n, func);
  for (int(i) = 0; (i) < (n); (i)++) {
    int j, k, l, m;
    j = i - 1;
    while (++j < n and d[in[j]] == d[in[i]] && g[in[j]] == 1)
      ;
    k = j - 1;
    while (++k < n and d[in[k]] == d[in[i]] && g[in[k]] == 2)
      ;
    l = j - 1, m = j;
    while (l >= i && m < k) {
      ans[in[l]] = make_pair(w, p[in[m]]);
      l--, m++;
    }
    m = j - 1;
    while (l >= i) {
      ans[in[l]] = make_pair(p[in[m]], h);
      l--, m--;
    }
    l = i, m = k - 1;
    while (l < j && m >= j) {
      ans[in[m]] = make_pair(p[in[l]], h);
      l++, m--;
    }
    l = k - 1;
    while (m >= j) {
      ans[in[m]] = make_pair(w, p[in[l]]);
      l--, m--;
    }
    i = k - 1;
  }
  ans.resize(n);
  for (auto [a, b] : ans) cout << a << ' ' << b << endl;
  return 0;
}
