#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <typename T>
inline void getint(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <typename T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int g[100100], p[100100], t[100100], ans[100100];
vector<pair<int, int> > vec[100100 << 1];
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", g + i, p + i, t + i);
  }
  for (int i = 0; i < n; i++) {
    if (g[i] == 1)
      vec[100100 + p[i] - t[i]].push_back(pair<int, int>(p[i], i));
    else
      vec[100100 + p[i] - t[i]].push_back(pair<int, int>(-p[i], i));
  }
  for (int i = 0; i < 100100 << 1; i++) {
    if (vec[i].empty()) continue;
    sort(vec[i].begin(), vec[i].end());
    int st = 0;
    for (int j = 0; j < vec[i].size(); j++) {
      if (vec[i][j].first > 0) {
        st = j;
        break;
      }
    }
    for (int j = 0; j < vec[i].size(); j++) {
      int u = vec[i][j].second;
      ans[u] = vec[i][(st + j) % vec[i].size()].first;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] > 0)
      printf("%d %d\n", ans[i], h);
    else
      printf("%d %d\n", w, -ans[i]);
  }
  return 0;
}
