#include <bits/stdc++.h>
using namespace std;
const int M = 400010, mod = 1000000007;
map<int, vector<pair<int, pair<int, int> > > > mep;
vector<pair<int, int> > first, second;
vector<pair<int, int> > a, b;
pair<int, int> ans[M];
int n, w, h;
void solve_for(vector<pair<int, pair<int, int> > > A) {
  int i, j, k;
  first.clear();
  second.clear();
  a.clear();
  b.clear();
  for (auto a : A) {
    if (a.second.first == 1)
      first.push_back(make_pair(a.second.second, a.first));
    else
      second.push_back(make_pair(a.second.second, a.first));
  }
  sort((first).begin(), (first).end());
  sort((second).begin(), (second).end());
  for (i = first.size() - 1; i >= 0; i--) a.push_back(first[i]);
  for (i = 0; i < second.size(); i++) a.push_back(second[i]);
  for (i = 0; i < second.size(); i++) b.push_back(second[i]);
  for (i = first.size() - 1; i >= 0; i--) b.push_back(first[i]);
  for (i = 0; i < first.size(); i++) {
    if (i < second.size())
      ans[a[i].second] = make_pair(w, b[i].first);
    else
      ans[a[i].second] = make_pair(b[i].first, h);
  }
  for (i = a.size() - 1, j = 0; j < second.size(); j++, i--) {
    if (j < first.size())
      ans[a[i].second] = make_pair(b[i].first, h);
    else
      ans[a[i].second] = make_pair(w, b[i].first);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, j, k;
  int g, p, t;
  scanf("%d%d%d", &n, &w, &h);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &g, &p, &t);
    mep[p - t].push_back(make_pair(i + 1, make_pair(g, p)));
  }
  for (auto v : mep) {
    solve_for(v.second);
  }
  for (i = 1; i <= n; i++) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
