#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
int n, w, h;
pair<int, int> pr[N];
map<int, vector<int> > have;
map<int, vector<pair<int, int> > > fin;
pair<int, int> ans[N];
int main() {
  scanf("%d %d %d", &n, &w, &h);
  for (int i = 0; i < n; i++) {
    int g, p, t;
    scanf("%d %d %d", &g, &p, &t);
    if (g == 1) {
      pr[i] = make_pair(p, -t);
      int sum = pr[i].first + pr[i].second;
      have[sum].push_back(i);
      fin[sum].push_back(make_pair(p, h));
    } else if (g == 2) {
      pr[i] = make_pair(-t, p);
      int sum = pr[i].first + pr[i].second;
      have[sum].push_back(i);
      fin[sum].push_back(make_pair(w, p));
    }
  }
  for (auto it : have) {
    sort(it.second.begin(), it.second.end(), [&](int i, int j) {
      if (pr[i].first == pr[j].first) return pr[i].second < pr[j].second;
      return pr[i].first < pr[j].first;
    });
    sort(fin[it.first].begin(), fin[it.first].end(),
         [&](pair<int, int> a, pair<int, int> b) {
           if (a.second == h && a.first != w) {
             if (b.second == h) return a.first < b.first;
             return true;
           }
           if (b.second == h && b.first != w) return false;
           return a.second > b.second;
         });
    for (int i = 0; i < (int)it.second.size(); i++) {
      ans[it.second[i]] = fin[it.first][i];
    }
  }
  for (int i = 0; i < n; i++) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
