#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 3e5 + 5;
const long long INF = 1e5 + 2;
long long p[N], g[N], t[N];
long long w, h;
vector<long long> idx[N];
pair<long long, long long> ans[N];
bool cmpr(long long i, long long j) {
  if (g[i] != g[j]) return (g[i] == 2);
  return (g[i] == 2 ? p[i] > p[j] : p[i] < p[j]);
}
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  cin >> w >> h;
  for (long long i = 0; i < n; i++) cin >> g[i] >> p[i] >> t[i];
  for (long long i = 0; i < n; i++) idx[p[i] - t[i] + 100005].push_back(i);
  vector<long long> x, y;
  for (long long i = 0; i < N; i++) {
    if (!idx[i].empty()) {
      for (int u : idx[i]) {
        if (g[u] == 1)
          x.push_back(p[u]);
        else
          y.push_back(p[u]);
      }
      sort(x.begin(), x.end());
      sort(y.begin(), y.end());
      sort(idx[i].begin(), idx[i].end(), cmpr);
      for (long long j = 0; j < x.size(); j++) {
        ans[idx[i][j]] = make_pair(x[j], h);
      }
      for (long long j = 0; j < y.size(); j++) {
        ans[idx[i][j + x.size()]] = make_pair(w, y[y.size() - j - 1]);
      }
      x.clear();
      y.clear();
    }
  }
  for (long long i = 0; i < n; i++)
    cout << ans[i].first << " " << ans[i].second << "\n";
  return 0;
}
