#include <bits/stdc++.h>
using namespace std;
const int kN = 1e5 + 10;
int N, W, H;
int G[kN], P[kN], T[kN];
int answer[kN][2];
vector<int> same_pmt[kN * 2];
void process(vector<int> &a) {
  vector<pair<int, int> > ans;
  vector<pair<int, int> > hor, vert;
  for (int i = 0; i < a.size(); i++) {
    int u = a[i];
    if (G[u] == 1) {
      vert.push_back(make_pair(P[u], u));
      ans.push_back(make_pair(P[u], H));
    } else {
      hor.push_back(make_pair(P[u], u));
      ans.push_back(make_pair(W, -P[u]));
    }
  }
  sort(ans.begin(), ans.end());
  sort(hor.begin(), hor.end());
  sort(vert.begin(), vert.end());
  int cnt = 0;
  for (int i = hor.size() - 1; i >= 0; i--) {
    int id = hor[i].second;
    answer[id][0] = ans[cnt].first;
    answer[id][1] = ans[cnt].second;
    cnt++;
  }
  for (int i = 0; i < vert.size(); i++) {
    int id = vert[i].second;
    answer[id][0] = ans[cnt].first;
    answer[id][1] = ans[cnt].second;
    cnt++;
  }
}
int main() {
  cin >> N >> W >> H;
  for (int i = 1; i <= N; i++) {
    cin >> G[i] >> P[i] >> T[i];
    same_pmt[P[i] - T[i] + kN].push_back(i);
  }
  for (int i = 0; i < 2 * kN; i++)
    if (same_pmt[i].size()) {
      process(same_pmt[i]);
    }
  for (int i = 1; i <= N; i++) {
    if (answer[i][1] < 0) answer[i][1] = -answer[i][1];
    printf("%d %d\n", answer[i][0], answer[i][1]);
  }
  return 0;
}
