#include <bits/stdc++.h>
using namespace std;
char getc() {
  char c = getchar();
  while ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9'))
    c = getchar();
  return c;
}
int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); }
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 << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x * f;
}
int n, w, h, ansx[100010], ansy[100010];
struct data {
  int op, x, t, i;
  bool operator<(const data& a) const { return x - t < a.x - a.t; }
} a[100010];
bool cmp(const data& a, const data& b) {
  return a.op < b.op || a.op == b.op && a.x < b.x;
}
signed main() {
  n = read(), w = read(), h = read();
  for (int i = 1; i <= n; i++)
    a[i].op = read(), a[i].x = read(), a[i].t = read(), a[i].i = i;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    int t = i;
    while (t < n && a[t + 1].x - a[t + 1].t == a[i].x - a[i].t) t++;
    sort(a + i, a + t + 1, cmp);
    int x = 0, y = 0;
    for (int j = i; j <= t; j++)
      if (a[j].op == 1)
        x++;
      else
        y++;
    for (int j = i; j < i + x; j++) {
      int W = i + x - j - 1, H = y, X = min(W, H);
      if (W >= H)
        ansx[a[j].i] = a[j + X].x, ansy[a[j].i] = h;
      else
        ansx[a[j].i] = w, ansy[a[j].i] = a[i + x + X].x;
    }
    for (int j = i + x; j <= t; j++) {
      int W = t - j, H = x, X = min(W, H);
      if (W >= H)
        ansx[a[j].i] = w, ansy[a[j].i] = a[j + X].x;
      else
        ansx[a[j].i] = a[i + X].x, ansy[a[j].i] = h;
    }
    i = t;
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", ansx[i], ansy[i]);
  return 0;
}
