#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int g[MAXN], p[MAXN], t[MAXN];
map<int, int> mp;
vector<int> gg[MAXN];
pair<int, int> ans[MAXN];
int n, w, h;
int cmp(int a, int b) {
  if (g[a] < g[b]) return 1;
  if (g[a] > g[b]) return 0;
  if (g[a] == 1) return p[a] < p[b];
  return p[a] > p[b];
}
int cmp2(int a, int b) {
  if (g[a] < g[b]) return 0;
  if (g[a] > g[b]) return 1;
  if (g[a] == 1) return p[a] < p[b];
  return p[a] > p[b];
}
int main() {
  cin >> n >> w >> h;
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &g[i], &p[i], &t[i]);
    if (!mp.count(p[i] - t[i])) mp[p[i] - t[i]] = ++tot;
    gg[mp[p[i] - t[i]]].push_back(i);
  }
  for (int i = 1; i <= tot; i++) {
    vector<int> tmp;
    tmp = gg[i];
    sort(gg[i].begin(), gg[i].end(), cmp);
    sort(tmp.begin(), tmp.end(), cmp2);
    for (int j = 0; j < tmp.size(); j++) {
      int pos = gg[i][j];
      if (g[pos] == 1)
        ans[tmp[j]] = make_pair(p[pos], h);
      else
        ans[tmp[j]] = make_pair(w, p[pos]);
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", ans[i].first, ans[i].second);
}
