#include <bits/stdc++.h>
using namespace std;
void inp();
int main() {
  inp();
  return 0;
}
int n, w, h;
const int N = 100000 + 1000;
const int N2 = N * 2;
vector<int> ve[N2];
int p[N], t[N], g[N];
int ansx[N], ansy[N];
vector<int> xs, ys;
void inp() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &g[i], &p[i], &t[i]);
    ve[p[i] - t[i] + N].push_back(i);
  }
  for (int I = 0; I < N2; I++) {
    xs.clear(), ys.clear();
    if (ve[I].empty()) continue;
    for (int x : ve[I]) {
      if (g[x] == 1)
        xs.push_back(p[x]);
      else
        ys.push_back(p[x]);
    }
    sort(((xs).begin()), ((xs).end()));
    sort(((ys).begin()), ((ys).end()), greater<int>());
    sort(((ve[I]).begin()), ((ve[I]).end()), [](int u, int v) {
      if (g[u] != g[v])
        return g[u] == 2;
      else
        return (g[u] == 2) ? p[u] > p[v] : p[u] < p[v];
    });
    for (int x : ve[I]) {
    }
    int cnt = 0;
    for (int x : xs) {
      ansx[ve[I][cnt]] = x;
      ansy[ve[I][cnt]] = h;
      cnt++;
    }
    for (int x : ys) {
      ansx[ve[I][cnt]] = w;
      ansy[ve[I][cnt]] = x;
      cnt++;
    }
    assert(cnt == ve[I].size());
  }
  for (int i = 0; i < n; i++) {
    printf("%d %d\n", ansx[i], ansy[i]);
  }
}
