#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
struct kk {
  int g, x, t, id;
  int z;
  kk() {}
  kk(int gg, int xx, int tt, int idd) {
    g = gg;
    x = xx;
    t = tt;
    id = idd;
    z = x - t;
  }
};
bool menor(const kk &a, const kk &b) {
  if (a.z == b.z) {
    return a.x < b.x;
  }
  return a.z < b.z;
};
int n, w, h;
kk arr[MAXN];
vector<kk> group[2][MAXN];
pair<int, int> sol[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> w >> h;
  for (int i = 0; i < (int)(n); i++) {
    int g, p, t;
    cin >> g >> p >> t;
    g--;
    arr[i] = kk(g, p, t, i);
  }
  sort(arr, arr + n, menor);
  int L = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (i == 0 || arr[i].z != arr[i - 1].z) {
      L++;
    }
    group[arr[i].g][L].push_back(arr[i]);
  }
  for (int gi = 0; gi < (int)(2); gi++) {
    for (int i = 1; i <= (int)(L); i++) {
      for (int j = 0; j < (int)(group[gi][i].size()); j++) {
        int a = group[gi][i].size() - j;
        int b = group[gi ^ 1][i].size();
        if (gi == 0) {
          if (a > b) {
            sol[group[gi][i][j].id] = pair<int, int>(group[gi][i][j + b].x, h);
          } else {
            sol[group[gi][i][j].id] =
                pair<int, int>(w, group[gi ^ 1][i][a - 1].x);
          }
        } else {
          if (a > b) {
            sol[group[gi][i][j].id] = pair<int, int>(w, group[gi][i][j + b].x);
          } else {
            sol[group[gi][i][j].id] =
                pair<int, int>(group[gi ^ 1][i][a - 1].x, h);
          }
        }
      }
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    cout << sol[i].first << ' ' << sol[i].second << '\n';
  }
}
