#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int offset = 100000;
template <class T>
int getbit(T x, int pos) {
  return (x >> (pos - 1)) & 1;
}
template <class T>
void turn_on(T &x, int pos) {
  x = x | ((T)1 << (pos - 1));
}
template <class T>
void turn_off(T &x, int pos) {
  x = x & ~((T)1 << (pos - 1));
}
template <class T>
T sqr(T a) {
  return a * a;
}
struct dancer {
  int type, x, t;
} a[100002];
int n, W, H, tmp[100002];
pair<int, int> res[100002];
vector<pair<int, int> > v;
deque<pair<int, int> > h;
vector<int> p[100002 + offset + 1];
void solve(const vector<int> &p) {
  v.clear();
  h.clear();
  for (int i = 0; i < (int)p.size(); ++i) {
    int id = p[i];
    if (a[id].type == 1)
      v.push_back(pair<int, int>(a[id].x, id));
    else
      h.push_back(pair<int, int>(a[id].x, id));
  }
  sort(v.begin(), v.end());
  sort(h.begin(), h.end());
  for (deque<pair<int, int> >::iterator it = h.begin(); it != h.end(); ++it) {
    tmp[it - h.begin() + 1] = it->first;
  }
  if (h.empty()) {
    for (int i = 0; i < (int)v.size(); ++i) {
      res[v[i].second] = pair<int, int>(v[i].first, H);
    }
    return;
  }
  for (int i = 0; i < (int)v.size(); ++i) {
    res[h.back().second] = pair<int, int>(v[i].first, H);
    h.pop_back();
    h.push_front(v[i]);
  }
  for (deque<pair<int, int> >::iterator it = h.begin(); it != h.end(); ++it) {
    res[it->second] = pair<int, int>(W, tmp[it - h.begin() + 1]);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> W >> H;
  int MAX = -inf, MIN = inf;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].type >> a[i].x >> a[i].t;
    p[a[i].x - a[i].t + offset].push_back(i);
    MAX = max(MAX, a[i].x - a[i].t + offset);
    MIN = min(MIN, a[i].x - a[i].t + offset);
  }
  for (int i = MIN; i <= MAX; ++i) {
    solve(p[i]);
  }
  for (int i = 1; i <= n; ++i)
    cout << res[i].first << ' ' << res[i].second << '\n';
}
