#include <bits/stdc++.h>
using namespace std;
const int dx4[5] = {0, -1, 0, 1, 0};
const int dy4[5] = {0, 0, 1, 0, -1};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int maxn = 2e5 + 3;
const double PI = acos(-1.0);
const long long mod = 1e9 + 7;
long long po(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}
void YES() {
  puts("YES");
  exit(0);
}
void Yes() {
  puts("Yes");
  exit(0);
}
void NO() {
  puts("NO");
  exit(0);
}
void No() {
  puts("No");
  exit(0);
}
void one() {
  puts("-1");
  exit(0);
}
int n, w, h;
map<int, vector<pair<pair<int, int>, int> > > pos;
pair<int, int> res[maxn];
pair<int, int> ans[maxn];
void solve() {
  scanf("%d", &(n)), scanf("%d", &(w)), scanf("%d", &(h));
  for (int i = 1; i <= n; i++) {
    int g, p, t;
    scanf("%d", &(g)), scanf("%d", &(p)), scanf("%d", &(t));
    pos[p - t].push_back(make_pair(make_pair(g, p), i));
    if (g == 1) {
      res[i].second = h;
      res[i].first = p;
    } else {
      res[i].first = w;
      res[i].second = p;
    }
  }
  for (auto val : pos) {
    vector<pair<pair<int, int>, int> > now = val.second;
    vector<pair<int, int> > xxx;
    vector<pair<int, int> > yyy;
    sort(now.begin(), now.end());
    for (int k = 0; k < now.size(); k++) {
      if (now[k].first.first == 1) {
        xxx.push_back(make_pair(now[k].first.second, now[k].second));
      } else {
        yyy.push_back(make_pair(now[k].first.second, now[k].second));
      }
    }
    int cnt = 0;
    for (int k = xxx.size() - 1; k >= 0; k--) {
      int fnow = 0;
      if (cnt < yyy.size()) {
        ans[xxx[k].second] = res[yyy[cnt].second];
        cnt++;
        fnow = 1;
      }
      if (fnow == 0) {
        ans[xxx[k].second] = res[xxx[k + yyy.size()].second];
      }
    }
    cnt = 0;
    for (int k = yyy.size() - 1; k >= 0; k--) {
      int fnow = 0;
      if (cnt < xxx.size()) {
        ans[yyy[k].second] = res[xxx[cnt].second];
        cnt++;
        fnow = 1;
      }
      if (fnow == 0) {
        ans[yyy[k].second] = res[yyy[k + xxx.size()].second];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
int main() {
  solve();
  return 0;
}
