#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vp = vector<pair<int, int> >;
using graph = vector<vector<int> >;
using db = double;
using ld = long double;
using pii = pair<int, int>;
const int Inf = 1000000000;
const ll MOD = 1000000007;
const ld PI = atan(1.0) * 4.0;
ll n, w, h, g, p, t;
map<ll, int> remx, remy;
vector<int> ix, iy;
vector<vp> fx, fy;
vp pr, ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> w >> h;
  ans.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> g >> p >> t;
    if (g == 1) {
      ll val = p - t;
      if (remx[val] == 0) {
        remx[val] = ix.size() + 1;
        ix.push_back(val);
        vp a;
        a.push_back({p, i});
        fx.push_back(a);
      } else {
        fx[remx[p - t] - 1].push_back({p, i});
      }
      pr.push_back({p, h});
    } else {
      ll val = p - t;
      if (remy[val] == 0) {
        remy[val] = iy.size() + 1;
        iy.push_back(val);
        vp a;
        a.push_back({p, i});
        fy.push_back(a);
      } else {
        fy[remy[p - t] - 1].push_back({p, i});
      }
      pr.push_back({w, p});
    }
  }
  int szx = fx.size(), szy = fy.size();
  for (int i = 0; i < szx; i++) sort(fx[i].begin(), fx[i].end());
  for (int i = 0; i < szy; i++) sort(fy[i].begin(), fy[i].end());
  for (int k = 0; k < szx; k++) {
    ll val = ix[k];
    if (remy[val] == 0) {
      for (int i = 0; i < fx[k].size(); i++) {
        ans[fx[k][i].second] = pr[fx[k][i].second];
      }
    } else {
      int indy = remy[val] - 1, skx = fx[k].size(), sky = fy[indy].size();
      for (int i = 0; i < skx - sky; i++) {
        ans[fx[k][i].second] = pr[fx[k][i + sky].second];
      }
      for (int i = max(skx - sky, 0); i < fx[k].size(); i++) {
        ans[fx[k][i].second] = pr[fy[indy][skx - i - 1].second];
      }
    }
  }
  for (int k = 0; k < szy; k++) {
    ll val = iy[k];
    if (remx[val] == 0) {
      for (int i = 0; i < fy[k].size(); i++) {
        ans[fy[k][i].second] = pr[fy[k][i].second];
      }
    } else {
      int indx = remx[val] - 1, sky = fy[k].size(), skx = fx[indx].size();
      for (int i = 0; i < sky - skx; i++) {
        ans[fy[k][i].second] = pr[fy[k][i + skx].second];
      }
      for (int i = max(sky - skx, 0); i < fy[k].size(); i++) {
        ans[fy[k][i].second] = pr[fx[indx][sky - i - 1].second];
      }
    }
  }
  for (int i = 0; i < n; i++)
    cout << ans[i].first << " " << ans[i].second << "\n";
  return 0;
}
