#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 100007;
const int MAX2 = 10007;
const int MAXE = 100000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 0;
pair<int, int> res[MAX];
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<pair<pair<int, int>, pair<pair<int, int>, pair<int, int> > > > A;
  for (int i = (0); i < (n); i++) {
    int g, p, t;
    scanf("%d%d%d", &g, &p, &t);
    t -= p;
    pair<int, int> a, b;
    if (g == 1) {
      a = make_pair(p, 0);
      b = make_pair(p, -h);
    } else {
      a = make_pair(0, -p);
      b = make_pair(w, -p);
    }
    A.push_back(make_pair(make_pair(t, i), make_pair(a, b)));
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < (int)A.size();) {
    int add = 1;
    while (i + add < (int)A.size() &&
           A[i + add].first.first == A[i].first.first)
      ++add;
    vector<pair<pair<int, int>, int> > B;
    vector<pair<int, int> > C;
    for (int j = (i); j < (i + add); j++) {
      B.push_back(make_pair(A[j].second.first, A[j].first.second));
      C.push_back(A[j].second.second);
    }
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    for (int j = (0); j < ((int)B.size()); j++) {
      res[B[j].second] = C[j];
    }
    i += add;
  }
  for (int i = (0); i < (n); i++) {
    printf("%d %d\n", res[i].first, -res[i].second);
  }
  return 0;
}
