#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, w, h;
int g[N], p[N], t[N];
pair<int, int> ans[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w >> h;
  map<int, vector<int> > ma;
  for (int i = (0); i < (n); i++) {
    cin >> g[i] >> p[i] >> t[i];
    ma[p[i] - t[i]].push_back(i);
  }
  for (auto &pa : ma) {
    vector<int> ve = pa.second;
    sort((ve).begin(), (ve).end(), [&](int i, int j) {
      if (g[i] != g[j]) return g[i] == 1;
      if (g[i] == 1) return p[i] > p[j];
      return p[i] < p[j];
    });
    vector<pair<int, int> > ve2;
    for (int i : ve) {
      if (g[i] == 1)
        ve2.emplace_back(p[i], h);
      else
        ve2.emplace_back(w, p[i]);
    }
    sort((ve2).begin(), (ve2).end(), [&](pair<int, int> &a, pair<int, int> &b) {
      return make_pair(a.first, -a.second) < make_pair(b.first, -b.second);
    });
    int k = ((int)(ve).size());
    for (int i = (0); i < (k); i++) {
      ans[ve[i]] = ve2[k - i - 1];
    }
  }
  for (int i = (0); i < (n); i++) {
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  }
}
