#include <bits/stdc++.h>
using namespace std;
const int CN = 1e5 + 10;
int read() {
  int s = 0, ne = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') ne = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) s = (s << 1) + (s << 3) + c - '0';
  return s * ne;
}
int n, W, H;
map<int, int> lib;
int idx = 0;
class PAIR {
 public:
  int a, b;
  bool operator<(const PAIR& o) const { return a ^ o.a ? a < o.a : b > o.b; }
};
PAIR mp(int a, int b) {
  PAIR o;
  o.a = a, o.b = b;
  return o;
}
vector<PAIR> id[CN], ed[CN];
int ansX[CN], ansY[CN];
int main() {
  n = read(), W = read(), H = read();
  for (int i = 1; i <= n; i++) {
    int tp = read(), p = read(), t = read(), x, y, u;
    if (tp == 2) {
      x = -t, y = p;
      if (!lib.count(x + y)) lib[x + y] = ++idx;
      u = lib[x + y];
      id[u].push_back(mp(x, i)), ed[u].push_back(mp(W, p));
    } else {
      x = p, y = -t;
      if (!lib.count(x + y)) lib[x + y] = ++idx;
      u = lib[x + y];
      id[u].push_back(mp(x, i)), ed[u].push_back(mp(p, H));
    }
  }
  for (int i = 1; i <= idx; i++)
    sort(id[i].begin(), id[i].end()), sort(ed[i].begin(), ed[i].end());
  for (int i = 1; i <= idx; i++) {
    for (int l = id[i].size(), j = 0; j < l; j++) {
      ansX[id[i][j].b] = ed[i][j].a;
      ansY[id[i][j].b] = ed[i][j].b;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", ansX[i], ansY[i]);
  return 0;
}
