#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 20;
struct node {
  int id, y;
  friend bool operator<(const node& a, const node& b) { return a.y < b.y; }
} no;
int n, w, h;
pair<int, int> ans[N];
int p[N];
set<node> a[N], s[N];
set<node>::iterator ita, its;
set<int> y[N];
set<int>::iterator it;
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; ++i) {
    int ty, t;
    scanf("%d%d%d", &ty, &p[i], &t);
    no.id = i;
    no.y = p[i];
    if (ty == 1) {
      a[t - p[i] + 100000].insert(no);
    } else {
      s[t - p[i] + 100000].insert(no);
      y[t - p[i] + 100000].insert(p[i]);
    }
  }
  for (int i = 0; i <= 200010; ++i) {
    for (ita = a[i].begin(); ita != a[i].end(); ita++) {
      if (!s[i].empty()) {
        node shang = *(--s[i].end()), xia = *(s[i].begin());
        ans[shang.id] = make_pair(1, p[(*ita).id]);
        s[i].erase(--s[i].end());
        xia.y--;
        xia.id = (*ita).id;
        s[i].insert(xia);
      } else {
        ans[(*ita).id] = make_pair(1, p[(*ita).id]);
      }
    }
    for (its = s[i].begin(), it = y[i].begin(); its != s[i].end();
         its++, it++) {
      ans[(*its).id] = make_pair(2, *it);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (ans[i].first == 1) {
      printf("%d %d\n", ans[i].second, h);
    } else {
      printf("%d %d\n", w, ans[i].second);
    }
  }
  return 0;
}
