#include <bits/stdc++.h>
using namespace std;
struct D {
  int l, t, id;
};
unordered_map<int, vector<D>> H, V;
unordered_map<int, int> id_shift;
pair<int, int> ans[(int)1e5];
int main() {
  ios::sync_with_stdio(0);
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < int(n); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 1)
      V[c - b].push_back({b, c, i});
    else
      H[c - b].push_back({b, c, i});
  }
  for (auto it : H)
    sort(H[it.first].begin(), H[it.first].end(),
         [](D a, D b) { return a.l < b.l; });
  for (auto it : V)
    sort(V[it.first].begin(), V[it.first].end(),
         [](D a, D b) { return a.l < b.l; });
  for (auto it : V) {
    if (H[it.first].empty()) {
      for (auto d : it.second) {
        ans[d.id] = {d.l, h};
      }
    } else {
      queue<int> Q;
      for (int i = int((int)H[it.first].size()) - 1; i >= int(0); i--)
        Q.push(H[it.first][i].id);
      for (auto d : it.second) {
        ans[Q.front()] = {d.l, h};
        Q.pop();
        Q.push(d.id);
      }
      for (int i = int((int)H[it.first].size()) - 1; i >= int(0); i--) {
        ans[Q.front()] = {w, H[it.first][i].l};
        Q.pop();
      }
    }
  }
  for (auto it : H)
    for (auto d : it.second)
      if (!ans[d.id].first) ans[d.id] = {w, d.l};
  for (int i = 0; i < int(n); i++)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  return 0;
}
