#include <bits/stdc++.h>
namespace fastIO {
bool IOerror = 0;
inline char nc() {
  static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 100000, stdin);
    if (pend == p1) {
      IOerror = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void read(int &x) {
  char ch;
  while (blank(ch = nc()))
    ;
  if (IOerror) return;
  for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0')
    ;
}
};  // namespace fastIO
template <class T>
inline T lowbit(T x) {
  return x & (-x);
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline bool scan(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
const double pi = 3.14159265358979323846264338327950288L;
using namespace std;
struct node {
  int op, p, t;
  int id;
  bool operator<(const node &a) const {
    return p - t < a.p - a.t || (p - t == a.p - a.t && p < a.p);
  }
};
map<int, vector<node> > mp1;
map<int, vector<node> >::iterator it1;
map<int, vector<pair<int, int> > > mp2;
map<int, vector<pair<int, int> > >::iterator it2;
bool cmp1(const node &a, const node &b) {
  if (a.op != b.op) return a.op > b.op;
  if (a.op == 1) {
    return a.p < b.p;
  } else {
    return a.p > b.p;
  }
}
bool cmp2(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first != b.first) {
    return a.first < b.first;
  } else {
    return a.second > b.second;
  }
}
int w, h, n;
pair<int, int> ans[100005];
int main() {
  mp1.clear();
  mp2.clear();
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    int op, p, t;
    scanf("%d%d%d", &op, &p, &t);
    mp1[p - t].push_back((node){op, p, t, i});
    if (op == 2) {
      mp2[p - t].push_back(make_pair(w, p));
    } else {
      mp2[p - t].push_back(make_pair(p, h));
    }
  }
  for (it1 = mp1.begin(), it2 = mp2.begin(); it1 != mp1.end(); it1++, it2++) {
    sort((it1->second).begin(), (it1->second).end(), cmp1);
    sort((it2->second).begin(), (it2->second).end(), cmp2);
    int sz = (it1->second).size();
    for (int i = 0; i < sz; i++) {
      ans[(it1->second)[i].id] = (it2->second)[i];
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
