#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct node {
  int x, y, id;
} a[N], b[N], ans[N];
inline int cmp(node A, node B) {
  return (A.x + A.y == B.x + B.y) ? (A.x < B.x) : (A.x + A.y < B.x + B.y);
}
inline int cmp2(node A, node B) {
  return (A.x == B.x) ? (A.y > B.y) : (A.x < B.x);
}
int main() {
  int n, w, h;
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; ++i) {
    int o, x, t;
    scanf("%d%d%d", &o, &x, &t);
    (o & 1) ? (a[i] = (node){x, -t, i}) : (a[i] = (node){-t, x, i});
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1, j; i <= n; i = j + 1) {
    j = i + 1;
    while (a[j].x + a[j].y == a[i].x + a[i].y && j <= n) ++j;
    --j;
    for (int k = i; k <= j; ++k)
      (a[k].y <= 0) ? (b[k] = (node){a[k].x, h, 0})
                    : (b[k] = (node){w, a[k].y, 0});
    sort(b + i, b + j + 1, cmp2);
    for (int k = i; k <= j; ++k) ans[a[k].id] = (node){b[k].x, b[k].y, 0};
  }
  for (int i = 1; i <= n; ++i) printf("%d %d\n", ans[i].x, ans[i].y);
}
