#include <bits/stdc++.h>
using namespace std;
int n, w, h;
int g[200001], p[200001], t[200001];
int a[200001];
int b[200001];
int x[200001], y[200001];
void qsort(int l, int r) {
  int i = l, j = r, q;
  int k = i + rand() % (j - i + 1);
  int m1 = g[k], m2 = p[k];
  int m0 = a[k];
  while (i <= j) {
    while (a[i] < m0 ||
           (a[i] == m0 && (g[i] > m1 || (g[i] == m1 && p[i] * (2 * g[i] - 3) >
                                                           m2 * (2 * m1 - 3)))))
      i++;
    while (m0 < a[j] ||
           (m0 == a[j] &&
            (m1 > g[j] ||
             (m1 == g[j] && m2 * (2 * m1 - 3) > p[j] * (2 * g[j] - 3)))))
      j--;
    if (i <= j) {
      q = g[i];
      g[i] = g[j];
      g[j] = q;
      q = p[i];
      p[i] = p[j];
      p[j] = q;
      q = t[i];
      t[i] = t[j];
      t[j] = q;
      q = a[i];
      a[i] = a[j];
      a[j] = q;
      q = b[i];
      b[i] = b[j];
      b[j] = q;
      i++;
      j--;
    }
  }
  if (i < r) qsort(i, r);
  if (l < j) qsort(l, j);
}
void work(int l, int r) {
  int i = l;
  while (i <= r && g[i] == 2) i++;
  for (int t = l; t <= r; t++) {
    if (i > r) i = l;
    if (g[i] == 1) {
      x[b[t]] = p[i];
      y[b[t]] = h;
    } else {
      x[b[t]] = w;
      y[b[t]] = p[i];
    }
    i++;
  }
}
int main() {
  srand(time(0));
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) cin >> g[i] >> p[i] >> t[i];
  for (int i = 0; i < n; i++) {
    a[i] = t[i] - p[i];
    b[i] = i;
  }
  qsort(0, n - 1);
  int i = 0;
  while (i < n) {
    int j = i;
    while (j < n && a[j] == a[i]) j++;
    work(i, j - 1);
    i = j;
  }
  for (int i = 0; i < n; i++) cout << x[i] << " " << y[i] << endl;
  return 0;
}
