#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long M = 1e5 + 7;
long long p[M], g[M], t[M];
map<long long, vector<long long> > mpx, mpy;
bool cmp(long long a, long long b) { return p[a] < p[b]; }
pair<long long, long long> kq[M];
int main() {
  long long n, w, h;
  cin >> n >> w >> h;
  for (long long i = 0; i < n; i++) {
    cin >> g[i] >> p[i] >> t[i];
    if (g[i] == 1) {
      mpx[p[i] - t[i]].push_back(i);
    } else {
      mpy[p[i] - t[i]].push_back(i);
    }
  }
  for (long long i = -M; i < M; i++) {
    long long nx = mpx[i].size();
    long long ny = mpy[i].size();
    sort(mpx[i].begin(), mpx[i].end(), cmp);
    sort(mpy[i].begin(), mpy[i].end(), cmp);
    for (long long k = 0; k < nx; k++) {
      if (nx - k > ny)
        kq[mpx[i][k]] = pair<long long, long long>(p[mpx[i][k + ny]], h);
      else
        kq[mpx[i][k]] = pair<long long, long long>(w, p[mpy[i][nx - k - 1]]);
    }
    for (long long k = 0; k < ny; k++) {
      if (ny - k > nx)
        kq[mpy[i][k]] = (pair<long long, long long>(w, p[mpy[i][k + nx]]));
      else
        kq[mpy[i][k]] = (pair<long long, long long>(p[mpx[i][ny - k - 1]], h));
    }
  }
  for (long long i = 0; i < n; i++)
    printf("%lld %lld\n", kq[i].first, kq[i].second);
}
