#include <bits/stdc++.h>
using namespace std;
struct dancer {
  int p, t, ind;
  dancer() = default;
  bool operator<(const dancer& x) const {
    return t < x.t || t == x.t && p < x.p;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  int n, w, h;
  cin >> n >> w >> h;
  vector<dancer> ver, hor;
  ver.reserve(n);
  hor.reserve(n);
  for (int i = 0; i < n; ++i) {
    int t;
    dancer tmp;
    cin >> t >> tmp.p >> tmp.t;
    tmp.ind = i;
    if (t == 1)
      ver.push_back(tmp);
    else
      hor.push_back(tmp);
  }
  vector<pair<int, int>> ans(n);
  int maxT = (int)1e5;
  auto fill = [&](const vector<dancer>& s, vector<vector<dancer>>& x) {
    for (const auto& dnc : s) {
      int ind = dnc.t - dnc.p + maxT;
      x[abs(ind)].push_back(dnc);
    }
    for (auto& v : x) sort(v.begin(), v.end());
  };
  auto collide = [&](vector<vector<dancer>>& a, vector<vector<dancer>>& b) {
    auto func = [&](int flag, int p) {
      if (flag) return make_pair(w, p);
      return make_pair(p, h);
    };
    for (int i = 0; i < 2 * maxT; ++i) {
      int flag = 0;
      if (a[i].size() < b[i].size()) {
        a[i].swap(b[i]);
        flag = 1;
      }
      int k = b[i].size(), q = a[i].size();
      for (int j = 0, p = q - 1; j < k; ++j, --p)
        ans[a[i][p].ind] = func(flag, b[i][j].p);
      for (int j = k - 1, p = 0; j > -1; --j, ++p)
        ans[b[i][j].ind] = func(flag ^ 1, a[i][p].p);
      for (int j = 0; j < q - k; ++j)
        ans[a[i][j].ind] = func(flag ^ 1, a[i][j + k].p);
    }
  };
  vector<vector<dancer>> a(2 * maxT), b(2 * maxT);
  fill(hor, a);
  fill(ver, b);
  collide(a, b);
  for (const auto& [x, y] : ans) cout << x << ' ' << y << '\n';
  return 0;
}
