#include <bits/stdc++.h>
using namespace std;
const int maxN = 100013;
int n, w, h, arr[maxN];
vector<int> all[3][maxN * 2];
pair<int, int> ans[maxN];
bool cmp(int i, int j) { return arr[i] < arr[j]; }
int main() {
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    int tp, t;
    cin >> tp >> arr[i] >> t;
    tp--;
    all[tp][maxN + arr[i] - t].push_back(i);
  }
  for (int i = 0; i < 2 * maxN; i++) {
    sort(all[0][i].begin(), all[0][i].end(), cmp);
    sort(all[1][i].begin(), all[1][i].end(), cmp);
  }
  for (int i = 0; i < maxN * 2; i++) {
    vector<int> x = all[0][i], y = all[1][i];
    if (x.empty() && y.empty()) continue;
    reverse(y.begin(), y.end());
    vector<pair<int, int>> answer;
    for (int j = 0; j < x.size(); j++)
      answer.push_back(make_pair(arr[x[j]], h));
    for (int j = 0; j < y.size(); j++)
      answer.push_back(make_pair(w, arr[y[j]]));
    for (int j = 0; j < x.size(); j++) y.push_back(x[j]);
    for (int j = 0; j < y.size(); j++) {
      ans[y[j]] = answer[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
