#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
int p[maxn], g[maxn], t[maxn];
int n, w, h;
const int offset = 100000 + 5;
vector<int> point[offset * 4];
set<int> Valid;
bool cmp(int A, int B) {
  if (g[A] != g[B])
    return g[A] == 2;
  else
    return g[A] == 2 ? p[A] > p[B] : p[A] < p[B];
}
pair<int, int> Ans[maxn];
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &g[i], &p[i], &t[i]);
    point[p[i] - t[i] + offset].push_back(i);
    Valid.insert(p[i] - t[i] + offset);
  }
  vector<int> xs, ys;
  for (set<int>::iterator ite = Valid.begin(); ite != Valid.end(); ++ite) {
    int co = *ite;
    xs.clear(), ys.clear();
    for (int j = 0; j < (int)point[co].size(); j++) {
      int idx = point[co][j];
      if (g[idx] == 1)
        xs.push_back(p[idx]);
      else
        ys.push_back(p[idx]);
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    sort(point[co].begin(), point[co].end(), cmp);
    for (int j = 0; j < (int)xs.size(); j++)
      Ans[point[co][j]] = make_pair(xs[j], h);
    for (int j = 0; j < (int)ys.size(); j++)
      Ans[point[co][j + xs.size()]] = make_pair(w, ys[ys.size() - j - 1]);
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", Ans[i].first, Ans[i].second);
  return 0;
}
