#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
int n, w, h, ans[N], gt[N];
pair<int, int> an[N];
vector<int> dif[2][2 * N], pt[2][2 * N];
vector<pair<pair<int, int>, int> > v[2];
int main() {
  cin >> n >> w >> h;
  for (int i = 0; i < n; ++i) ans[i] = gt[i] = i;
  for (int a, b, c, i = 0; i < n; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1)
      an[i] = pair<int, int>(b, h);
    else
      an[i] = pair<int, int>(w, b);
    v[a - 1].push_back(make_pair(pair<int, int>(b, c), i));
  }
  sort((v[0]).begin(), (v[0]).end());
  sort((v[1]).begin(), (v[1]).end());
  reverse((v[1]).begin(), (v[1]).end());
  for (int k = 0; k < 2; ++k)
    for (int i = 0; i < v[k].size(); ++i) {
      dif[k][v[k][i].first.second - v[k][i].first.first + N].push_back(
          v[k][i].second);
      pt[k][v[k][i].first.second - v[k][i].first.first + N].push_back(
          v[k][i].second);
    }
  for (int i = 0; i < v[0].size(); ++i) {
    int idx = v[0][i].second;
    int diff = v[0][i].first.second - v[0][i].first.first + N;
    vector<int> &tt = dif[1][diff];
    int ct = pt[1][diff].size();
    if (!ct) continue;
    ans[tt[tt.size() - ct]] = idx;
    tt.push_back(idx);
  }
  for (int i = 0; i < 2 * N; ++i) {
    vector<int> &tt = dif[1][i];
    vector<int> &pp = pt[1][i];
    if (pp.empty()) continue;
    for (int i = tt.size() - 1; tt.size() - i <= pp.size(); --i)
      ans[tt[i]] = pp[pp.size() - (tt.size() - i)];
  }
  for (int i = 0; i < n; ++i)
    printf("%d %d\n", an[ans[i]].first, an[ans[i]].second);
}
