#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int n, w, h;
int g[MAXN], p[MAXN], t[MAXN], perm[MAXN];
vector<pair<int, int> > v[2 * MAXN];
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);
    if (g[i] == 1) {
      v[p[i] - t[i] + MAXN].push_back({p[i], i});
    } else {
      v[p[i] - t[i] + MAXN].push_back({-t[i], i});
    }
  }
  for (int i = 0; i < 2 * MAXN; i++) {
    sort(v[i].begin(), v[i].end());
    int sz = v[i].size();
    int id = -1;
    for (int j = 1; j < sz; j++) {
      if ((v[i][j].first > 0) && (v[i][j - 1].first <= 0)) {
        id = j;
        break;
      }
    }
    if (id == -1) {
      for (int j = 0; j < sz; j++) {
        perm[v[i][j].second] = v[i][j].second;
      }
    } else {
      for (int j = 0; j < sz; j++) {
        perm[v[i][j].second] = v[i][(j + id) % sz].second;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (g[perm[i]] == 1) {
      printf("%d %d\n", p[perm[i]], h);
    } else {
      printf("%d %d\n", w, p[perm[i]]);
    }
  }
  return 0;
}
