#include <bits/stdc++.h>
using namespace std;
const int maxn = 100009;
int g[maxn], p[maxn], t[maxn], n, w, h, x[maxn], y[maxn], co_x[maxn],
    co_y[maxn];
vector<int> v[maxn * 2];
bool cmp(int x, int y) {
  if (g[x] != g[y])
    return g[x] == 2;
  else {
    if (g[x] == 1)
      return p[x] < p[y];
    else
      return p[x] > p[y];
  }
}
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &g[i], &p[i], &t[i]);
    v[p[i] - t[i] + maxn].push_back(i);
  }
  for (int i = 0; i < maxn * 2; ++i) {
    int numx = 0, numy = 0;
    for (int j = 0; j < v[i].size(); ++j) {
      int xx = v[i][j];
      if (g[xx] == 1)
        x[numx++] = p[xx];
      else
        y[numy++] = p[xx];
    }
    sort(x, x + numx);
    sort(y, y + numy);
    sort(v[i].begin(), v[i].end(), cmp);
    for (int j = 0; j < numx; ++j) {
      co_x[v[i][j]] = x[j];
      co_y[v[i][j]] = h;
    }
    for (int j = 0; j < numy; ++j) {
      co_x[v[i][numx + j]] = w;
      co_y[v[i][numx + j]] = y[numy - j - 1];
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d %d\n", co_x[i], co_y[i]);
  }
  return 0;
}
