#include <bits/stdc++.h>
using namespace std;
struct person {
  int id, pos;
  person(int a, int b) : id(a), pos(b) {}
  bool operator<(const person &o) const { return pos < o.pos; }
};
int main() {
  unordered_map<int, vector<person>> a;
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    int g, p, t;
    cin >> g >> p >> t;
    a[p - t].push_back(person(i, g == 1 ? p : -p));
  }
  vector<int> at(n);
  for (auto &x : a) {
    auto &g = x.second;
    sort(g.begin(), g.end());
    int s =
        count_if(g.begin(), g.end(), [](const person &x) { return x.pos < 0; });
    for (int i = 0; i < g.size(); i++) at[g[i].id] = g[(i + s) % g.size()].pos;
  }
  for (int p : at)
    if (p < 0)
      cout << w << ' ' << -p << endl;
    else
      cout << p << ' ' << h << endl;
  return 0;
}
