#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vec[2][200005];
pair<int, int> ans[200005];
int main() {
  int i, j, n, w, h, opt, p, t, sz1, sz2;
  cin >> n >> w >> h;
  for (i = 1; i <= n; i++) {
    cin >> opt >> p >> t;
    vec[opt - 1][p - t + 100000].push_back(make_pair(p, i));
  }
  for (i = 1; i <= 200000; i++) {
    sort(vec[0][i].begin(), vec[0][i].end());
    sort(vec[1][i].begin(), vec[1][i].end());
    sz1 = vec[0][i].size();
    sz2 = vec[1][i].size();
    for (j = 0; j < sz1; j++) {
      if (sz1 - j - 1 >= sz2)
        ans[vec[0][i][j].second] = make_pair(vec[0][i][j + sz2].first, h);
      else
        ans[vec[0][i][j].second] = make_pair(w, vec[1][i][sz1 - j - 1].first);
    }
    for (j = 0; j < sz2; j++) {
      if (sz2 - j - 1 >= sz1)
        ans[vec[1][i][j].second] = make_pair(w, vec[1][i][j + sz1].first);
      else
        ans[vec[1][i][j].second] = make_pair(vec[0][i][sz2 - j - 1].first, h);
    }
  }
  for (i = 1; i <= n; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
