#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, w, d;
  cin >> n >> w >> d;
  unordered_map<int, vector<pair<int, int>>> x_axis;
  unordered_map<int, vector<pair<int, int>>> y_axis;
  set<int> distinct_val;
  for (int i = 0; i < n; i++) {
    int axis;
    cin >> axis;
    if (axis == 1) {
      int val, start_time;
      cin >> val >> start_time;
      x_axis[val - start_time].push_back(make_pair(val, i));
      distinct_val.insert(val - start_time);
    } else {
      int val, start_time;
      cin >> val >> start_time;
      y_axis[val - start_time].push_back(make_pair(val, i));
      distinct_val.insert(val - start_time);
    }
  }
  vector<pair<int, int>> ans(n);
  for (auto it : distinct_val) {
    int num = it;
    int m = y_axis[num].size();
    n = x_axis[num].size();
    sort(x_axis[num].begin(), x_axis[num].end());
    sort(y_axis[num].begin(), y_axis[num].end());
    for (int i = 0; i < n; i++) {
      if (n - 1 - i >= m) {
        ans[x_axis[num][i].second] = make_pair(x_axis[num][i + m].first, d);
      } else {
        ans[x_axis[num][i].second] = make_pair(w, y_axis[num][n - i - 1].first);
      }
    }
    for (int i = 0; i < m; i++) {
      if (m - 1 - i >= n) {
        ans[y_axis[num][i].second] = make_pair(w, y_axis[num][i + n].first);
      } else {
        ans[y_axis[num][i].second] = make_pair(x_axis[num][m - i - 1].first, d);
      }
    }
  }
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return;
}
int main() {
  solve();
  return 0;
}
