#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
int g[100010], p[100010], t[100010], finalPoint[100010];
map<int, vector<pii>> points;
void addPoint(int x, int y, int id) { points[x + y].emplace_back(x, id); }
int main() {
  int n, w, h, i, mid, diff, sgn;
  cin >> n >> w >> h;
  for (i = 1; i <= n; ++i) {
    cin >> g[i] >> p[i] >> t[i];
    if (g[i] == 1)
      addPoint(p[i], -t[i], i);
    else
      addPoint(-t[i], p[i], i);
  }
  for (auto entry : points) {
    auto vec = entry.second;
    sort(vec.begin(), vec.end());
    for (mid = 0; mid < vec.size() && vec[mid].first <= 0; ++mid)
      ;
    for (i = 0; i < mid && i + mid < vec.size(); ++i)
      finalPoint[vec[i].second] = vec[i + mid].second;
    for (i = vec.size() - 1; i >= mid && i >= vec.size() - mid; --i)
      finalPoint[vec[i].second] = vec[i - vec.size() + mid].second;
    if (mid < vec.size() - mid)
      diff = mid, sgn = 1;
    else
      diff = vec.size() - mid, sgn = -1;
    for (i = 0; i < vec.size(); ++i)
      if (finalPoint[vec[i].second] == 0)
        finalPoint[vec[i].second] = vec[i + sgn * diff].second;
  }
  for (i = 1; i <= n; ++i) {
    if (g[finalPoint[i]] == 1)
      cout << p[finalPoint[i]] << ' ' << h << '\n';
    else
      cout << w << ' ' << p[finalPoint[i]] << '\n';
  }
  return 0;
}
