#include <bits/stdc++.h>
using namespace std;
inline int rd(void) {
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  int x = 0;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int N = 100005;
int n, w, h;
int g[N], p[N], t[N];
int Hash[N], tot;
inline int Find(int w) {
  return lower_bound(Hash + 1, Hash + tot + 1, w) - Hash;
}
struct point {
  int x, y, id;
  friend inline bool operator<(point A, point B) {
    return A.x != B.x ? A.x < B.x : A.y > B.y;
  }
};
vector<point> End[N], Lis[N];
point Go[N];
int main(void) {
  n = rd(), w = rd(), h = rd();
  for (register int i = (1); i <= (n); i++)
    g[i] = rd(), p[i] = rd(), t[i] = rd(), Hash[++tot] = p[i] - t[i];
  sort(Hash + 1, Hash + tot + 1);
  tot = unique(Hash + 1, Hash + tot + 1) - Hash - 1;
  for (register int i = (1); i <= (n); i++) {
    int Belong = Find(p[i] - t[i]);
    if (g[i] == 1) {
      End[Belong].push_back((point){p[i], h, 0});
      Lis[Belong].push_back((point){p[i], 0, i});
    } else {
      End[Belong].push_back((point){w, p[i], 0});
      Lis[Belong].push_back((point){0, p[i], i});
    }
  }
  for (register int i = (1); i <= (tot); i++) {
    sort(End[i].begin(), End[i].end());
    sort(Lis[i].begin(), Lis[i].end());
    for (vector<point>::iterator itE = End[i].begin(), itL = Lis[i].begin();
         itE != End[i].end(); itE++, itL++)
      Go[itL->id] = *itE;
  }
  for (register int i = (1); i <= (n); i++) printf("%d %d\n", Go[i].x, Go[i].y);
  return 0;
}
