#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, id;
  bool operator<(const node& e) const {
    if (x == e.x) return y > e.y;
    return x < e.x;
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, w, h;
  cin >> n >> w >> h;
  vector<vector<node>> a(200005);
  for (int i = 0; i < n; i++) {
    int g, p, t;
    node v;
    v.id = i;
    cin >> g >> p >> t;
    if (g == 1) {
      v.y = 0;
      v.x = p;
    } else {
      v.x = 0;
      v.y = p;
    }
    a[p - t + 100000].push_back(v);
  }
  vector<node> ans(n);
  for (auto& i : a) {
    auto b = i;
    sort(i.begin(), i.end());
    for (auto& j : b) {
      if (j.x == 0)
        j.x = w;
      else
        j.y = h;
    }
    sort(b.begin(), b.end());
    for (int j = 0; j < b.size(); j++) {
      ans[i[j].id] = b[j];
    }
  }
  for (auto i : ans) cout << i.x << ' ' << i.y << endl;
}
