#include <bits/stdc++.h>
using namespace std;
const int MAXD = 200000;
const int MAXN = 100000;
vector<pair<int, int> > vecX[MAXD + 10], vecY[MAXD + 10];
int respx[MAXN + 10], respy[MAXN + 10], w, h;
int p[MAXN + 10], g[MAXN + 10], t[MAXN + 10], n;
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &g[i], &p[i], &t[i]);
    if (g[i] == 1) {
      vecX[p[i] - t[i] + 100000].push_back(make_pair(p[i], i));
      respx[i] = p[i], respy[i] = h;
    } else {
      vecY[p[i] - t[i] + 100000].push_back(make_pair(p[i], i));
      respx[i] = w, respy[i] = p[i];
    }
  }
  for (int i = 1; i <= MAXD; i++) {
    if (!vecX[i].size() || !vecY[i].size()) continue;
    int szX = vecX[i].size(), szY = vecY[i].size();
    sort(vecX[i].begin(), vecX[i].end());
    sort(vecY[i].begin(), vecY[i].end());
    for (int j = 0; j < szX; j++) {
      if (j + szY < szX) {
        respx[vecX[i][j].second] = p[vecX[i][j + szY].second];
      } else {
        respx[vecX[i][j].second] = w;
        respy[vecX[i][j].second] = p[vecY[i][szX - j - 1].second];
      }
    }
    for (int j = 0; j < szY; j++) {
      if (j + szX < szY) {
        respy[vecY[i][j].second] = p[vecY[i][j + szX].second];
      } else {
        respy[vecY[i][j].second] = h;
        respx[vecY[i][j].second] = p[vecX[i][szY - j - 1].second];
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", respx[i], respy[i]);
  return 0;
}
