#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, w, h, g[N], x[N], t[N], idx[N];
map<int, vector<int> > hs;
void solve() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &g[i], &x[i], &t[i]);
    hs[x[i] - t[i]].push_back(i);
  }
  for (auto vec : hs) {
    vector<int> xs, ys, v;
    for (auto it : vec.second) {
      if (g[it] == 1)
        xs.push_back(it);
      else
        ys.push_back(it);
      v.push_back(it);
    }
    sort(xs.begin(), xs.end(), [&](int a, int b) { return x[a] < x[b]; });
    sort(ys.begin(), ys.end(), [&](int a, int b) { return x[a] > x[b]; });
    sort(v.begin(), v.end(), [&](int a, int b) {
      if (g[a] != g[b]) return g[a] == 1;
      return g[a] == 1 ? x[a] < x[b] : x[a] > x[b];
    });
    for (int i = 0; i < ys.size(); i++) {
      idx[ys[i]] = v[i];
    }
    for (int i = 0; i < xs.size(); i++) {
      idx[xs[i]] = v[i + ys.size()];
    }
  }
  for (int i = 0; i < n; i++) {
    if (g[idx[i]] == 1)
      printf("%d %d\n", x[idx[i]], h);
    else
      printf("%d %d\n", w, x[idx[i]]);
  }
}
int main() {
  solve();
  return 0;
}
