#include <bits/stdc++.h>
using namespace std;
int n, w, h;
int gi[100003];
int pi[100003];
int ti[100003];
int di[100003];
map<int, vector<int> > collision;
bool cmp(int k1, int k2) {
  return (gi[k1] > gi[k2] || (gi[k1] == 1 && gi[k2] == 1 && pi[k1] > pi[k2]) ||
          (gi[k1] == 2 && gi[k2] == 2 && pi[k1] < pi[k2]));
}
bool cmp2(int k1, int k2) {
  return (gi[k1] < gi[k2] || (gi[k1] == 1 && gi[k2] == 1 && pi[k1] > pi[k2]) ||
          (gi[k1] == 2 && gi[k2] == 2 && pi[k1] < pi[k2]));
}
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &gi[i], &pi[i], &ti[i]);
    di[i] = i;
    collision[pi[i] - ti[i]].push_back(i);
  }
  map<int, vector<int> >::iterator it;
  for (it = collision.begin(); it != collision.end(); it++) {
    vector<int> vect = it->second;
    sort(vect.begin(), vect.end(), cmp);
    vector<int> vect2 = vect;
    sort(vect2.begin(), vect2.end(), cmp2);
    for (int i = 0; i < vect.size(); i++) {
      di[vect2[i]] = vect[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (gi[di[i]] == 1) {
      printf("%d %d\n", pi[di[i]], h);
    } else {
      printf("%d %d\n", w, pi[di[i]]);
    }
  }
}
