#include <bits/stdc++.h>
using namespace std;
struct pp {
  long long first, second, t, k, id, fx, fy;
} vet[101010];
int n, w, h, ansx[101010], ansy[101010];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> w >> h;
  for (int(i) = (0); (i) < (n); (i)++) {
    long long tp, p;
    cin >> tp >> p >> vet[i].t;
    if (tp == 1)
      vet[i].first = p, vet[i].second = 0, vet[i].fx = p, vet[i].fy = h;
    else
      vet[i].first = 0, vet[i].second = p, vet[i].fx = w, vet[i].fy = p;
    vet[i].id = i;
    vet[i].k = vet[i].first + vet[i].second - vet[i].t;
  }
  sort(vet, vet + n, [](pp a, pp b) { return a.k < b.k; });
  int l = 0, r;
  while (l < n) {
    r = l;
    while (r + 1 < n && vet[r + 1].k == vet[l].k) r++;
    vector<pp> first, second;
    for (int(i) = (l); (i) < (r + 1); (i)++) {
      if (vet[i].first)
        first.push_back(vet[i]);
      else
        second.push_back(vet[i]);
    }
    vector<int> ids;
    sort((first).begin(), (first).end(),
         [](pp a, pp b) { return a.first > b.first; });
    sort((second).begin(), (second).end(),
         [](pp a, pp b) { return a.second < b.second; });
    for (int(i) = (0); (i) < (((int)(first).size())); (i)++)
      ids.push_back(first[i].id);
    for (int(i) = (0); (i) < (((int)(second).size())); (i)++)
      ids.push_back(second[i].id);
    for (int(i) = (0); (i) < (((int)(first).size())); (i)++)
      second.push_back(first[i]);
    for (int(i) = (0); (i) < (((int)(ids).size())); (i)++) {
      ansx[ids[i]] = second[i].fx;
      ansy[ids[i]] = second[i].fy;
    }
    l = r + 1;
  }
  for (int(i) = (0); (i) < (n); (i)++) printf("%d %d\n", ansx[i], ansy[i]);
}
