#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, w, h;
struct Point {
  int d, p, id;
  bool operator<(const Point& r) const { return p < r.p; }
};
vector<Point> px[N], py[N];
int ansx[N], ansy[N], tmpx[N], tmpy[N];
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 0; i < n; ++i) {
    int g, p, t;
    scanf("%d%d%d", &g, &p, &t);
    if (g == 1)
      px[p - t + 100000].push_back({0, p, i});
    else
      py[p - t + 100000].push_back({1, p, i});
  }
  for (int i = 0; i < N; ++i) sort(px[i].begin(), px[i].end());
  for (int i = 0; i < N; ++i) sort(py[i].begin(), py[i].end());
  for (int i = 0; i < N; ++i) {
    int cur = 0;
    for (int j = 0; j < px[i].size(); ++j)
      tmpx[cur] = px[i][j].p, tmpy[cur] = h, ++cur;
    for (int j = (int)py[i].size() - 1; j >= 0; --j)
      tmpx[cur] = w, tmpy[cur] = py[i][j].p, ++cur;
    cur = 0;
    for (int j = (int)py[i].size() - 1; j >= 0; --j)
      ansx[py[i][j].id] = tmpx[cur], ansy[py[i][j].id] = tmpy[cur], ++cur;
    for (int j = 0; j < px[i].size(); ++j)
      ansx[px[i][j].id] = tmpx[cur], ansy[px[i][j].id] = tmpy[cur], ++cur;
  }
  for (int i = 0; i < n; ++i) printf("%d %d\n", ansx[i], ansy[i]);
  return 0;
}
