#include <bits/stdc++.h>
using namespace std;
long long n, w, h, g[((long long)101 * 1000)], x[((long long)101 * 1000)],
    t[((long long)101 * 1000)];
vector<pair<long long, long long> > vec[2][3 * ((long long)101 * 1000)];
pair<long long, long long> ans[((long long)101 * 1000)];
long long out[((long long)101 * 1000)];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    cin >> g[i] >> x[i] >> t[i];
    if (g[i] == 1) {
      ans[i] = {x[i], h};
      vec[0][t[i] - x[i] + ((long long)101 * 1000)].push_back({x[i], i});
    }
    if (g[i] == 2) {
      ans[i] = {w, x[i]};
      vec[1][t[i] - x[i] + ((long long)101 * 1000)].push_back({x[i], i});
    }
  }
  for (int i = 0; i < 3 * ((long long)101 * 1000); i++) {
    if (!vec[0][i].size() && !vec[1][i].size()) continue;
    sort(vec[0][i].begin(), vec[0][i].end());
    sort(vec[1][i].begin(), vec[1][i].end());
    if (vec[0][i].size() > vec[1][i].size()) swap(vec[0][i], vec[1][i]);
    for (int j = (long long)vec[0][i].size() - 1, k = 0; j >= 0; j--, k++)
      out[vec[0][i][j].second] = vec[1][i][k].second;
    for (int j = (long long)vec[1][i].size() - 1, k = 0;
         k < (long long)vec[0][i].size(); j--, k++)
      out[vec[1][i][j].second] = vec[0][i][k].second;
    for (int j = 0, k = vec[0][i].size();
         j < (long long)vec[1][i].size() - (long long)vec[0][i].size();
         j++, k++)
      out[vec[1][i][j].second] = vec[1][i][k].second;
  }
  for (int i = 0; i < n; i++)
    cout << ans[out[i]].first << " " << ans[out[i]].second << "\n";
  return 0;
}
