#include <bits/stdc++.h>
using namespace std;
int p[100005], g[100005], t[100005];
vector<int> v[100005 + 100005];
vector<int> a, b;
pair<int, int> ans[100005];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    cin >> g[i] >> p[i] >> t[i];
    v[p[i] - t[i] + 100005].push_back(i);
  }
  for (int i = 0; i < 100005 + 100005; i++) {
    if (v[i].empty()) continue;
    for (int j : v[i]) {
      if (g[j] == 1)
        a.push_back(p[j]);
      else
        b.push_back(p[j]);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(v[i].begin(), v[i].end(), [](int x, int y) {
      if (g[x] != g[y]) return g[x] == 2;
      return g[x] == 2 ? p[x] > p[y] : p[x] < p[y];
    });
    for (int j = 0; j < a.size(); j++) {
      ans[v[i][j]].first = a[j];
      ans[v[i][j]].second = h;
    }
    for (int j = 0; j < b.size(); j++) {
      ans[v[i][j + a.size()]].first = w;
      ans[v[i][j + a.size()]].second = b[b.size() - j - 1];
    }
    a.clear();
    b.clear();
  }
  for (int i = 0; i < n; i++)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  return 0;
}
