#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > vec1(312345), vec2(312346);
int g[123456], p[123456], t[123456];
int cons;
int h, w;
int computeup(int i) {
  int val1, val;
  vector<int>::iterator it;
  val1 = t[i] - p[i] + cons;
  it = upper_bound(vec1[val1].begin(), vec1[val1].end(), p[i]);
  val = vec2[val1].size();
  int siz = vec1[val1].end() - it;
  it--;
  if (val <= siz) {
    it += val;
    cout << *it << " " << h << endl;
  } else {
    cout << w << " " << vec2[val1][siz] << endl;
  }
  return 0;
}
int computehor(int i) {
  int val1, val;
  vector<int>::iterator it;
  val1 = t[i] - p[i] + cons;
  it = upper_bound(vec2[val1].begin(), vec2[val1].end(), p[i]);
  val = vec1[val1].size();
  int siz = vec2[val1].end() - it;
  it--;
  if (val <= siz) {
    it += val;
    cout << w << " " << *it << endl;
  } else {
    cout << vec1[val1][siz] << " " << h << endl;
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n >> w >> h;
  cons = 100010;
  int i;
  for (i = 0; i < n; i++) {
    cin >> g[i] >> p[i] >> t[i];
    if (g[i] == 1)
      vec1[t[i] - p[i] + cons].push_back(p[i]);
    else
      vec2[t[i] - p[i] + cons].push_back(p[i]);
  }
  for (i = 0; i < 212345; i++) {
    sort(vec1[i].begin(), vec1[i].end());
    sort(vec2[i].begin(), vec2[i].end());
  }
  for (i = 0; i < n; i++) {
    if (g[i] == 1)
      computeup(i);
    else
      computehor(i);
  }
  return 0;
}
