#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int big = 1e9 + 10;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;
template <class T, class U>
void mineq(T& a, U b) {
  if (a > b) {
    a = b;
  }
}
template <class T, class U>
void maxeq(T& a, U b) {
  if (a < b) {
    a = b;
  }
}
long long int gcd(long long int a, long long int b) {
  if (a % b == 0) {
    return b;
  } else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
const int ioi = 100000;
int main(void) {
  int n, i, j, w, h;
  cin >> n >> w >> h;
  vector<vector<tuple<int, int, int>>> zone(2 * ioi + 5);
  vector<tuple<int, int, int>> ans(n);
  for (i = 0; i < n; i++) {
    int g, p, t;
    cin >> g >> p >> t;
    zone[ioi + p - t].push_back(make_tuple(g, p, i));
  }
  for (i = 0; i < zone.size(); i++) {
    vector<pair<int, int>> sta(zone[i].size());
    for (j = 0; j < zone[i].size(); j++) {
      if (get<0>(zone[i][j]) == 2) {
        get<1>(zone[i][j]) = -get<1>(zone[i][j]);
      }
      sta[j] = make_pair(get<1>(zone[i][j]), get<2>(zone[i][j]));
    }
    sort(zone[i].begin(), zone[i].end());
    sort(sta.begin(), sta.end());
    for (j = 0; j < zone[i].size(); j++) {
      if (get<0>(zone[i][j]) == 2) {
        get<1>(zone[i][j]) = -get<1>(zone[i][j]);
      }
      ans[sta[j].second] = zone[i][j];
    }
  }
  for (i = 0; i < n; i++) {
    if (get<0>(ans[i]) == 1) {
      cout << get<1>(ans[i]) << " " << h << endl;
    } else {
      cout << w << " " << get<1>(ans[i]) << endl;
    }
  }
  return 0;
}
