#include <bits/stdc++.h>
using namespace std;
const int N = 101000;
const int zero = 110000;
struct edge {
  int x, y, index;
  edge(){};
  edge(int xx, int yy, int zz) {
    x = xx;
    y = yy;
    index = zz;
  }
};
struct node {
  int x, y;
} b[N];
vector<edge> v[N * 3];
vector<int> t;
int e[N];
bool cmp1(const edge &a, const edge &b) {
  if (a.x == b.x) {
    if (a.x == 1) return a.y > b.y;
    return a.y < b.y;
  }
  return a.x > b.x;
}
bool cmp2(const edge &a, const edge &b) {
  if (a.x == b.x) {
    if (a.x == 1) return a.y > b.y;
    return a.y < b.y;
  }
  return a.x < b.x;
}
int n, w, h, x, y, z, pos;
int main() {
  while (scanf("%d%d%d", &n, &w, &h) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d%d%d", &x, &y, &z);
      if (x == 1) {
        b[i].x = y;
        b[i].y = h;
        pos = zero + z - y;
        v[pos].push_back(edge(1, y, i));
      } else {
        b[i].x = w;
        b[i].y = y;
        pos = zero + z - y;
        v[pos].push_back(edge(2, y, i));
      }
    }
    for (int i = 0; i < N * 3; i++) {
      if (v[i].size() < 1) continue;
      sort(v[i].begin(), v[i].end(), cmp1);
      t.clear();
      for (int j = 0; j < v[i].size(); j++) t.push_back(v[i][j].index);
      sort(v[i].begin(), v[i].end(), cmp2);
      for (int j = 0; j < v[i].size(); j++) e[v[i][j].index] = t[j];
    }
    for (int i = 1; i <= n; i++) printf("%d %d\n", b[e[i]].x, b[e[i]].y);
  }
  return 0;
}
