#include <bits/stdc++.h>
const int N = 2e5;
int n, w, h;
std::pair<int, int> ans[N + 5];
std::vector<int> p[N + 5], q[N + 5];
struct People {
  int opt, t, x;
} a[N + 5];
int main() {
  scanf("%d%d%d", &n, &w, &h);
  std::vector<int> vec;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i].opt, &a[i].x, &a[i].t);
    vec.push_back(a[i].t - a[i].x);
  }
  std::sort(vec.begin(), vec.end());
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  for (int i = 1; i <= n; i++) {
    int t = std::lower_bound(vec.begin(), vec.end(), a[i].t - a[i].x) -
            vec.begin() + 1;
    (a[i].opt == 1 ? q[t] : p[t]).push_back(i);
  }
  for (int t = 1; t <= n * 2; t++) {
    if (p[t].empty() && q[t].empty()) {
      continue;
    }
    std::sort(p[t].begin(), p[t].end(),
              [](int x, int y) { return a[x].x < a[y].x; });
    std::sort(q[t].begin(), q[t].end(),
              [](int x, int y) { return a[x].x < a[y].x; });
    int r = (int)p[t].size(), c = (int)q[t].size();
    for (int i = 0; i < (int)r; i++) {
      int k = std::min(c, r - i);
      ans[p[t][i]] = i + k < r ? std::make_pair(w, a[p[t][i + k]].x)
                               : std::make_pair(a[q[t][k - 1]].x, h);
    }
    for (int i = 0; i < (int)c; i++) {
      int k = std::min(r, c - i);
      ans[q[t][i]] = (i + k < c ? std::make_pair(a[q[t][i + k]].x, h)
                                : std::make_pair(w, a[p[t][k - 1]].x));
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
