#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int g[N], p[N], t[N];
vector<int> group[N * 2];
int ansx[N], ansy[N];
bool cmp(int i, int j) {
  if (g[i] == g[j]) return g[i] == 1 ? p[i] < p[j] : p[i] > p[j];
  return g[i] == 2;
}
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    cin >> g[i] >> p[i] >> t[i];
    group[p[i] - t[i] + N].push_back(i);
  }
  vector<int> x, y;
  for (int i = 0; i < N * 2; i++) {
    if (!group[i].empty()) {
      for (int j = 0; j < group[i].size(); j++) {
        if (g[group[i][j]] == 1)
          x.push_back(p[group[i][j]]);
        else
          y.push_back(p[group[i][j]]);
      }
      sort(x.begin(), x.end());
      sort(y.begin(), y.end());
      sort(group[i].begin(), group[i].end(), cmp);
      int j = 0;
      for (int k = 0; k < x.size(); ++k, ++j) {
        ansx[group[i][j]] = x[k];
        ansy[group[i][j]] = h;
      }
      for (int k = y.size() - 1; k >= 0; --k, ++j) {
        ansx[group[i][j]] = w;
        ansy[group[i][j]] = y[k];
      }
      x.clear();
      y.clear();
    }
  }
  for (int i = 0; i < n; i++) cout << ansx[i] << " " << ansy[i] << endl;
}
