#include <bits/stdc++.h>
using namespace std;
int n, w, h, i, j, x, y, z;
pair<int, int> res[233333];
vector<pair<pair<int, int>, int> > s[233333], t[233333];
int main() {
  ios::sync_with_stdio(false);
  ;
  cin >> n >> w >> h;
  for (i = 1; i <= n; i++) {
    cin >> x >> y >> z;
    if (x == 2) {
      s[y - z + 100000].push_back(make_pair(make_pair(0, -y), i));
      t[y - z + 100000].push_back(make_pair(make_pair(w, -y), i));
    } else {
      s[y - z + 100000].push_back(make_pair(make_pair(y, 0), i));
      t[y - z + 100000].push_back(make_pair(make_pair(y, h), i));
    }
  }
  for (i = 0; i <= 200000; i++) {
    if (s[i].empty()) {
      continue;
    }
    stable_sort(s[i].begin(), s[i].end());
    stable_sort(t[i].begin(), t[i].end());
    for (j = 0; j < s[i].size(); j++) {
      res[s[i][j].second] = t[i][j].first;
    }
  }
  for (i = 1; i <= n; i++)
    cout << res[i].first << ' ' << abs(res[i].second) << endl;
  return 0;
}
