#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 10;
void file(string s) {
  freopen((s + ".in").c_str(), "r", stdin),
      freopen((s + ".out").c_str(), "w", stdout);
}
long long read() {
  long long f = 1, a = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    a = a * 10 + ch - '0';
    ch = getchar();
  }
  return a * f;
}
struct node {
  long long id, opt, p, t;
  node() {}
  node(long long _id, long long _opt, long long _p, long long _t) {
    id = _id, opt = _opt, p = _p, t = _t;
  }
  bool operator<(const node b) const { return p - t < b.p - b.t; }
} num[MAXN];
struct ANS {
  long long x, y;
  ANS() {}
  ANS(long long _x, long long _y) { x = _x, y = _y; }
} ans[MAXN];
long long n, w, h;
vector<node> v;
inline bool cmp1(node x, node y) {
  if (x.opt != y.opt)
    return x.opt < y.opt;
  else if (x.opt == 1)
    return x.p < y.p;
  else
    return x.p > y.p;
}
inline bool cmp2(node x, node y) {
  if (x.opt != y.opt)
    return x.opt > y.opt;
  else if (x.opt == 1)
    return x.p < y.p;
  else
    return x.p > y.p;
}
void calc() {
  if (v.size() <= 1) {
    v.clear();
    return;
  }
  vector<node> v1;
  vector<ANS> re;
  for (long long i = 0; i < v.size(); ++i) {
    v1.push_back(v[i]);
  }
  sort(v1.begin(), v1.end(), cmp1), sort(v.begin(), v.end(), cmp2);
  for (long long i = 0; i < v.size(); ++i) {
    re.push_back(ans[v1[i].id]);
  }
  for (long long i = 0; i < v.size(); ++i) {
    ans[v[i].id] = re[i];
  }
  v.clear();
}
signed main() {
  n = read(), h = read(), w = read();
  for (long long i = 1; i <= n; ++i) {
    long long opt = read(), p = read(), t = read();
    num[i] = node(i, opt, p, t);
    if (opt == 1) {
      ans[i] = ANS(w, p);
    } else {
      ans[i] = ANS(p, h);
    }
  }
  sort(num + 1, num + n + 1);
  long long las = 0;
  for (long long i = 1; i <= n; ++i) {
    if (i != 1 && num[i].p - num[i].t != las) {
      calc();
    }
    v.push_back(num[i]);
    las = num[i].p - num[i].t;
  }
  calc();
  for (long long i = 1; i <= n; ++i) {
    cout << ans[i].y << ' ' << ans[i].x << endl;
  }
  return 0;
}
