#include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
const int MAXN = 1e5;
int n, w, h, u, r, g[200010], p[200010], ans[200010], t[200010];
vector<int> v[200010];
pair<int, int> U[200010], R[200010];
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; i++) {
    getint(g[i]), getint(p[i]), getint(t[i]);
    v[p[i] - t[i] + MAXN].push_back(i);
  }
  for (int i = 0; i <= 199999; i++)
    if (v[i].size()) {
      u = r = 0;
      for (int j = 0; j < v[i].size(); ++j)
        if (g[v[i][j]] == 1)
          U[++u] = make_pair(p[v[i][j]], v[i][j]);
        else
          R[++r] = make_pair(p[v[i][j]], v[i][j]);
      sort(U + 1, U + u + 1);
      sort(R + 1, R + r + 1);
      for (int j = 1; j <= u; j++) {
        if (u - j <= r - 1)
          ans[U[j].second] = R[u - j + 1].second;
        else
          ans[U[j].second] = U[r + j].second;
      }
      for (int j = 1; j <= r; j++) {
        if (r - j <= u - 1)
          ans[R[j].second] = U[r - j + 1].second;
        else
          ans[R[j].second] = R[u + j].second;
      }
    }
  for (int i = 1; i <= n; i++)
    if (g[ans[i]] == 1)
      printf("%d %d\n", p[ans[i]], h);
    else
      printf("%d %d\n", w, p[ans[i]]);
  return 0;
}
