#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int maxn = 100010;
const long long mod = 1e9 + 7;
const int inf = 1e9;
int n, w, h;
pair<int, int> a[maxn];
vector<pair<int, int> > X, Y;
vector<pair<int, int> > vec1, vec2;
pair<int, int> ans[maxn];
int main() {
  scanf("%d%d%d", &n, &w, &h);
  int g, x, y, t;
  for (int i = 0; i < n; i++) {
    scanf("%d", &g);
    scanf("%d", &x);
    scanf("%d", &t);
    if (g == 1) {
      y = 0;
      X.push_back({t - x, i});
    } else {
      y = x;
      x = 0;
      Y.push_back({t - y, i});
    }
    a[i] = {x, y};
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  int p1 = 0;
  int p2 = 0;
  while (p1 < X.size() || p2 < Y.size()) {
    vec1.clear();
    vec2.clear();
    int curt = inf;
    if (p1 < X.size()) {
      curt = X[p1].first;
      vec1.push_back({a[X[p1].second].first, X[p1].second});
      p1++;
    }
    while (p1 < X.size() && X[p1].first == curt) {
      vec1.push_back({a[X[p1].second].first, X[p1].second});
      p1++;
    }
    while (p2 < Y.size() && Y[p2].first < curt) {
      ans[Y[p2].second] = {w, a[Y[p2].second].second};
      p2++;
    }
    while (p2 < Y.size() && Y[p2].first == curt) {
      vec2.push_back({a[Y[p2].second].second, Y[p2].second});
      p2++;
    }
    sort(vec1.begin(), vec1.end());
    sort(vec2.begin(), vec2.end());
    int cntx = (int)vec1.size();
    for (int i = 0; i < vec2.size(); i++) {
      if (cntx - 1 >= i) {
        ans[vec1[cntx - 1 - i].second] = {w, vec2[i].first};
      } else {
        ans[vec2[i - cntx].second] = {w, vec2[i].first};
      }
    }
    int cnty = (int)vec2.size();
    for (int i = 0; i < vec1.size(); i++) {
      if (cnty - 1 >= i) {
        ans[vec2[cnty - 1 - i].second] = {vec1[i].first, h};
      } else {
        ans[vec1[i - cnty].second] = {vec1[i].first, h};
      }
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
