#include <bits/stdc++.h>
using namespace std;
int n, w, h;
struct ed1 {
  int x, y, clas, id, ANSx, ANSy;
} p[2000099];
struct ed2 {
  int x, y, clas;
} ans[2000099];
bool cmp1(const ed1 &A, const ed1 &B) {
  if (A.clas != B.clas) return A.clas < B.clas;
  return A.x < B.x;
}
bool cmp2(const ed2 &A, const ed2 &B) {
  if (A.clas != B.clas) return A.clas < B.clas;
  if (A.x != B.x) return A.x < B.x;
  return A.y > B.y;
}
bool cmp3(const ed1 &A, const ed1 &B) { return A.id < B.id; }
int main() {
  cin >> n >> w >> h;
  for (int i = 1, g; i <= n; i++) {
    scanf("%d", &g);
    if (g == 1) {
      scanf("%d%d", &p[i].x, &p[i].y);
      p[i].y *= -1;
    } else if (g == 2) {
      scanf("%d%d", &p[i].y, &p[i].x);
      p[i].x *= -1;
    }
    p[i].clas = p[i].x + p[i].y;
    p[i].id = i;
  }
  sort(p + 1, p + 1 + n, cmp1);
  for (int i = 1; i <= n; i++) {
    ans[i].clas = p[i].clas;
    if (p[i].x <= 0) {
      ans[i].x = w;
      ans[i].y = p[i].y;
    } else if (p[i].y <= 0) {
      ans[i].y = h;
      ans[i].x = p[i].x;
    }
  }
  sort(ans + 1, ans + 1 + n, cmp2);
  for (int i = 1; i <= n; i++) {
    p[i].ANSx = ans[i].x;
    p[i].ANSy = ans[i].y;
  }
  sort(p + 1, p + 1 + n, cmp3);
  for (int i = 1; i <= n; i++) printf("%d %d\n", p[i].ANSx, p[i].ANSy);
  return 0;
}
