#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, w, h;
  cin >> n >> w >> h;
  vector<pair<pair<int, int>, pair<int, int> > > a;
  for (int i = 0; i < n; i++) {
    int first, second, z;
    cin >> first >> second >> z;
    z -= second;
    a.push_back(make_pair(make_pair(z, first), make_pair(second, i)));
  }
  sort(a.begin(), a.end());
  int i = 0;
  vector<pair<int, int> > ans(n);
  while (i != n) {
    int ind = i;
    int curr = a[i].first.first;
    int c1 = 0, c2 = 0;
    while (i != n && a[i].first.first == curr && a[i].first.second == 1)
      i++, c1++;
    while (i != n && a[i].first.first == curr && a[i].first.second == 2)
      i++, c2++;
    for (int j = ind; j < ind + c1; j++) {
      int curr1 = c1 - (j - ind) - 1;
      int curr2 = c2;
      if (curr1 == 0 && curr2 == 0)
        ans[a[j].second.second] = make_pair(a[j].second.first, h);
      if (curr1 >= curr2) {
        ans[a[j].second.second] = make_pair(a[j + curr2].second.first, h);
      } else {
        ans[a[j].second.second] =
            make_pair(w, a[ind + c1 + curr1].second.first);
      }
    }
    for (int j = ind + c1; j < ind + c1 + c2; j++) {
      int curr1 = c2 - (j - ind - c1) - 1;
      int curr2 = c1;
      if (curr1 == 0 && curr2 == 0)
        ans[a[j].second.second] = make_pair(w, a[j].second.first);
      else if (curr1 >= curr2) {
        ans[a[j].second.second] = make_pair(w, a[j + curr2].second.first);
      } else {
        ans[a[j].second.second] = make_pair(a[ind + curr1].second.first, h);
      }
    }
  }
  for (int i = 0; i < n; i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
