#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 500050;
int n, w, h, base = 200050;
map<int, deque<int> > mp;
vector<pair<int, int> > G[maxn];
struct node {
  int id, p, val;
  friend bool operator<(node a, node b) { return a.p < b.p; }
};
vector<node> T;
int A[maxn], vis[maxn];
int main() {
  cin >> n >> w >> h;
  for (int i = 1; i <= n; i++) {
    int g, p, t;
    scanf("%d%d%d", &g, &p, &t);
    if (g == 1) {
      G[t - p + base].push_back(make_pair(p, i));
    } else {
      T.push_back(node{i, p, t - p + base});
    }
  }
  for (int i = 0; i < maxn; i++) {
    sort(G[i].begin(), G[i].end());
    for (int j = 0; j < G[i].size(); j++) {
      mp[i].push_back(G[i][j].second);
    }
  }
  sort(T.begin(), T.end());
  for (int i = 0; i < T.size(); i++) {
    if (mp[T[i].val].empty()) {
      A[T[i].id] = T[i].p;
      vis[T[i].id] = 1;
    } else {
      int pos = mp[T[i].val].back();
      A[pos] = T[i].p;
      vis[pos] = 1;
      mp[T[i].val].pop_back();
      mp[T[i].val].push_front(T[i].id);
    }
  }
  for (auto it : mp) {
    int num = 0;
    while (!(it.second).empty()) {
      int x = (it.second).front();
      (it.second).pop_front();
      A[x] = G[it.first][num++].first;
      vis[x] = 2;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 1)
      printf("%d %d", w, A[i]);
    else
      printf("%d %d", A[i], h);
    puts("");
  }
}
