#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000005;
const int sz = 100000 + 5;
int x[sz], y[sz];
int n;
map<int, vector<int> > group;
int ansx[sz], ansy[sz];
struct sortx {
  bool operator()(const int a, const int b) const {
    if (x[a] == x[b]) throw 2;
    return x[a] < x[b];
  }
};
int w, h;
void solve(vector<int> g) {
  sort(g.begin(), g.end(), sortx());
  vector<int> g2;
  list<int> g1;
  for (auto ind : g) {
    if (x[ind] <= 0)
      g1.push_back(ind);
    else
      g2.push_back(ind);
  }
  if (g1.empty()) {
    for (auto ind : g) {
      ansx[ind] = x[ind];
      ansy[ind] = h;
    }
    return;
  }
  vector<int> g3(g1.begin(), g1.end());
  for (auto ind : g2) {
    int top = g1.front();
    g1.pop_front();
    ansx[top] = x[ind];
    ansy[top] = h;
    g1.push_back(ind);
  }
  vector<int> ans1(g1.begin(), g1.end());
  for (int i = 0; i < ans1.size(); ++i) {
    int right = ans1[i];
    int ind = g3[i];
    ansx[right] = w;
    ansy[right] = y[ind];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int g, p, t;
  cin >> n >> w >> h;
  for (int i = 0; i < n; ++i) {
    cin >> g >> p >> t;
    if (g == 1) {
      x[i] = p;
      y[i] = -t;
    } else {
      x[i] = -t;
      y[i] = p;
    }
    group[x[i] + y[i]].push_back(i);
  }
  for (auto it : group) {
    solve(it.second);
  }
  for (int i = 0; i < n; ++i) {
    cout << ansx[i] << " " << ansy[i] << endl;
  }
  return 0;
}
