#include <bits/stdc++.h>
using namespace std;
const int MAXT = 100000;
const int MAXN = 200005;
int g[MAXN], p[MAXN], t[MAXN];
vector<int> x[MAXN], y[MAXN];
int ansx[MAXN], ansy[MAXN];
bool comp(int x, int y) { return p[x] < p[y]; }
int main() {
  int n, w, h;
  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) x[p[i] - t[i] + MAXT].push_back(i);
    if (g[i] == 2) y[p[i] - t[i] + MAXT].push_back(i);
  }
  for (int i = 0; i <= 200000; i++) {
    if (x[i].empty() && y[i].empty()) continue;
    int s1 = x[i].size();
    int s2 = y[i].size();
    sort(x[i].begin(), x[i].end(), comp);
    sort(y[i].begin(), y[i].end(), comp);
    for (int j = 0; j < s1; j++) {
      if (s1 - j <= s2) {
        ansx[x[i][j]] = w;
        ansy[x[i][j]] = p[y[i][s1 - 1 - j]];
      } else {
        ansx[x[i][j]] = p[x[i][s2 + j]];
        ansy[x[i][j]] = h;
      }
    }
    for (int j = 0; j < s2; j++) {
      if (s2 - j <= s1) {
        ansx[y[i][j]] = p[x[i][s2 - 1 - j]];
        ansy[y[i][j]] = h;
      } else {
        ansx[y[i][j]] = w;
        ansy[y[i][j]] = p[y[i][s1 + j]];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d %d\n", ansx[i], ansy[i]);
  }
  return 0;
}
