#include <bits/stdc++.h>
using namespace std;
int ai[100005];
pair<int, int> ans[100005];
vector<tuple<int, int, int>> f[200005], t[200005];
int main() {
  int n, w, h;
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 0; i < n; i++) {
    ai[i] = i;
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      ans[i] = {b, h};
      f[100000 + c - b].emplace_back(b, -c, i);
      t[100000 + c - b].emplace_back(b, h, i);
    } else {
      ans[i] = {w, b};
      f[100000 + c - b].emplace_back(-c, b, i);
      t[100000 + c - b].emplace_back(w, b, i);
    }
  }
  auto cmp = [](tuple<int, int, int> &a, tuple<int, int, int> &b) {
    if (get<0>(a) == get<0>(b)) return get<1>(a) > get<1>(b);
    return get<0>(a) < get<0>(b);
  };
  for (int i = 0; i <= 200000; i++) {
    sort(f[i].begin(), f[i].end(), cmp);
    sort(t[i].begin(), t[i].end(), cmp);
    int m = f[i].size();
    for (int j = 0; j < m; j++) {
      ai[get<2>(f[i][j])] = get<2>(t[i][j]);
    }
  }
  for (int i = 0; i < n; i++)
    printf("%d %d\n", ans[ai[i]].first, ans[ai[i]].second);
}
