#include <bits/stdc++.h>
using namespace std;
long long n, w, h;
long long g[100005], p[100005], t[100005];
map<long long, vector<pair<long long, long long> > > mp;
pair<long long, long long> ans[100005];
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> w >> h;
  for (long long(i) = (1); (i) <= (n); (i)++) {
    cin >> g[i] >> p[i] >> t[i];
    long long d = p[i] + t[i];
    if (g[i] == 2) d *= -1;
    mp[p[i] - t[i]].push_back(pair<long long, long long>(d, i));
  }
  for (auto z : mp) {
    vector<pair<long long, long long> > &vec = z.second;
    sort((vec).begin(), (vec).end());
    vector<pair<long long, pair<long long, long long> > > gvec;
    for (auto v : vec) {
      long long id = v.second;
      if (g[id] == 1)
        gvec.push_back(pair<long long, pair<long long, long long> >(
            p[id] - h, pair<long long, long long>(p[id], h)));
      else
        gvec.push_back(pair<long long, pair<long long, long long> >(
            w - p[id], pair<long long, long long>(w, p[id])));
    }
    sort((gvec).begin(), (gvec).end());
    for (long long(i) = (0); (i) <= ((int)vec.size() - 1); (i)++)
      ans[vec[i].second] = gvec[i].second;
  }
  for (long long(i) = (1); (i) <= (n); (i)++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
