#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mx = 1e5;
int n, w, h, g, p, t, x[N], y[N];
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
struct node {
  int pos, id, w;
} a[N], b[N];
bool cmp(node a, node b) { return a.w == b.w ? a.pos < b.pos : a.w < b.w; }
int main() {
  n = read();
  w = read();
  h = read();
  for (int i = 1; i <= n; i++) {
    g = read();
    p = read();
    t = read();
    b[i].w = a[i].w = p - t;
    b[i].id = a[i].id = i;
    if (g == 1) {
      a[i].pos = mx + p;
      b[i].pos = p;
    } else {
      a[i].pos = mx - p;
      b[i].pos = mx + mx - p;
    }
  }
  sort(a + 1, a + n + 1, cmp);
  sort(b + 1, b + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    if (b[i].pos <= mx) {
      x[a[i].id] = b[i].pos;
      y[a[i].id] = h;
    } else {
      x[a[i].id] = w;
      y[a[i].id] = mx - b[i].pos + mx;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", x[i], y[i]);
  return 0;
}
