#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > f[3][200100];
pair<int, int> ans[100100], res[100100];
int g[100100], p[100100], t[100100];
int n, h, w;
void work(vector<pair<int, int> > &f, vector<pair<int, int> > &g) {
  int n = f.size(), m = g.size();
  for (int i = 0; i < n; ++i) {
    if (m >= n)
      ans[f[i].second] = res[g[n - i - 1].second];
    else {
      if (i + m < n)
        ans[f[i].second] = res[f[i + m].second];
      else
        ans[f[i].second] = res[g[n - i - 1].second];
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", g + i, p + i, t + i);
    f[g[i]][t[i] - p[i] + 100000].push_back(make_pair(p[i], i));
    res[i] = ans[i] = g[i] == 1 ? make_pair(p[i], h) : make_pair(w, p[i]);
  }
  for (int i = 1; i <= 200000; ++i) {
    if (f[1][i].size() && f[2][i].size()) {
      sort(f[1][i].begin(), f[1][i].end());
      sort(f[2][i].begin(), f[2][i].end());
      work(f[1][i], f[2][i]);
      work(f[2][i], f[1][i]);
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
