#include <bits/stdc++.h>
using namespace std;
int n, w, h, g[110000], p[110000], t[110000], a[110000], b[110000];
set<int> sx[2 * 110000], sy[2 * 110000];
map<pair<int, int>, int> ansx;
map<pair<int, int>, int> ansy;
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)
      sx[p[i] - t[i] + 110000].insert(p[i]);
    else
      sy[p[i] - t[i] + 110000].insert(p[i]);
  }
  for (int i = 0; i < 2 * 110000; i++) {
    if (sx[i].size()) {
      a[0] = b[0] = 0;
      for (auto t : sx[i]) a[++a[0]] = t;
      for (auto t : sy[i]) b[++b[0]] = t;
      for (int j = 1; j <= a[0]; j++)
        if (b[0] + 1 <= a[0] - j + 1)
          ansx[pair<int, int>(a[j], i)] = a[j + b[0]];
        else
          ansx[pair<int, int>(a[j], i)] = -b[a[0] - j + 1];
    }
    if (sy[i].size()) {
      a[0] = b[0] = 0;
      for (auto t : sy[i]) a[++a[0]] = t;
      for (auto t : sx[i]) b[++b[0]] = t;
      for (int j = 1; j <= a[0]; j++)
        if (b[0] + 1 <= a[0] - j + 1)
          ansy[pair<int, int>(a[j], i)] = -a[j + b[0]];
        else
          ansy[pair<int, int>(a[j], i)] = b[a[0] - j + 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    int k;
    if (g[i] == 1)
      k = ansx[pair<int, int>(p[i], p[i] - t[i] + 110000)];
    else
      k = ansy[pair<int, int>(p[i], p[i] - t[i] + 110000)];
    if (k > 0)
      printf("%d %d\n", k, h);
    else
      printf("%d %d\n", w, -k);
  }
  return 0;
}
