#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > m[200200];
vector<pair<int, int> > finish[200200];
pair<int, int> ans[100100];
bool cmp(pair<int, int> a, pair<int, int> b) {
  return a.first - a.second < b.first - b.second;
}
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < n; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    if (x == 1)
      x = y, y = 0;
    else
      x = 0;
    m[x + y - c + 100100].push_back({x - y, i});
    if (!x)
      finish[y - c + 100100].push_back({w, y});
    else
      finish[x - c + 100100].push_back({x, h});
  }
  for (int i = 0; i < 200200; ++i) {
    sort(m[i].begin(), m[i].end());
    sort(finish[i].begin(), finish[i].end(), cmp);
    for (int j = 0; j < m[i].size(); ++j) ans[m[i][j].second] = finish[i][j];
  }
  for (int i = 0; i < n; ++i)
    cout << ans[i].first << " " << ans[i].second << endl;
}
