#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 1e4 + 10;
const long long Zero = 1e5 + 10;
vector<pair<int, int> > a[MAXN];
vector<pair<int, int> > b[MAXN];
vector<int> c[MAXN];
pair<int, int> res[MAXN / 2];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  long long n, w, h;
  cin >> n >> w >> h;
  for (long long i = 0; i < n; i++) {
    long long x, p, t;
    cin >> x >> p >> t;
    if (x == 1) {
      a[Zero + p - t].push_back(make_pair(p, i));
    } else {
      b[Zero + p - t].push_back(make_pair(p, i));
    }
  }
  for (long long i = 0; i < MAXN; i++) {
    sort(a[i].begin(), a[i].end());
    sort(b[i].begin(), b[i].end());
    for (long long j = 0; j < a[i].size(); j++) {
      c[i].push_back(a[i][j].second);
    }
    reverse(c[i].begin(), c[i].end());
  }
  for (long long i = MAXN - 1; i >= 0; i--) {
    if (!a[i].empty()) {
      long long u = 0;
      for (long long j = 0; j < b[i].size(); j++) {
        res[c[i][u]].first = w;
        res[c[i][u++]].second = b[i][j].first;
        c[i].push_back(b[i][j].second);
      }
      reverse(c[i].begin(), c[i].end());
      c[i].resize((long long)(a[i].size()));
      b[i].clear();
    }
  }
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < a[i].size(); j++) {
      res[c[i][j]].first = a[i][j].first;
      res[c[i][j]].second = h;
    }
    for (long long j = 0; j < b[i].size(); j++) {
      res[b[i][j].second].first = w;
      res[b[i][j].second].second = b[i][j].first;
    }
  }
  for (long long i = 0; i < n; i++) {
    cout << res[i].first << " " << res[i].second << endl;
  }
}
