#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
int n, a, b, op[N], p[N], t[N], ansx[N], ansy[N];
vector<int> vec[(N << 1) + 3];
struct Dot {
  int x, y;
} dot[N];
inline void LOCAL() { freopen("1.in", "r", stdin); }
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = 10 * x + c - '0';
    c = getchar();
  }
  x *= f;
}
bool cmp(int a, int b) {
  int x = (op[a] == 1) ? p[a] : -t[a];
  int y = (op[b] == 1) ? p[b] : -t[b];
  return x < y;
}
bool cmp1(Dot a, Dot b) { return a.x != b.x ? a.x < b.x : a.y > b.y; }
int main() {
  read(n);
  read(a);
  read(b);
  for (int i = 1; i <= n; i++) {
    read(op[i]);
    read(p[i]);
    read(t[i]);
    vec[p[i] - t[i] + N].push_back(i);
  }
  for (int i = 1; i <= N << 1; i++)
    if (vec[i].size()) {
      sort(vec[i].begin(), vec[i].end(), cmp);
      int len = vec[i].size();
      for (int j = 0; j <= len - 1; j++) {
        int pos = vec[i][j];
        if (op[pos] == 1) {
          dot[j].x = p[pos];
          dot[j].y = b;
        } else {
          dot[j].x = a;
          dot[j].y = p[pos];
        }
      }
      sort(dot, dot + len, cmp1);
      for (int j = 0; j <= len - 1; j++) {
        int pos = vec[i][j];
        ansx[pos] = dot[j].x;
        ansy[pos] = dot[j].y;
      }
    }
  for (int i = 1; i <= n; i++) printf("%d %d\n", ansx[i], ansy[i]);
  return 0;
}
