#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <typename T>
void read(T &a) {
  T x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  a = x * f;
}
template <typename T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10) return (void)putchar(x + '0');
  write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  putchar('\n');
}
template <typename T>
void writes(T x) {
  write(x);
  putchar(' ');
}
template <typename T, typename... Args>
void read(T &maxx, Args &...args) {
  read(maxx);
  read(args...);
}
template <typename T, typename... Args>
void writes(T maxx, Args... args) {
  writes(maxx);
  writes(args...);
}
template <typename T, typename... Args>
void writeln(T maxx, Args... args) {
  writes(maxx);
  writes(args...);
  putchar('\n');
}
long long n, w, h, cnt;
map<long long, long long> mp;
struct node {
  long long x, y;
} ans[100005];
struct QwQ {
  long long id, t, p, opt;
} a[100005];
vector<QwQ> v[100005], v2[100005];
signed main() {
  read(n, w, h);
  for (long long i = 1; i <= n; i++) {
    read(a[i].opt, a[i].p, a[i].t);
    if (a[i].opt == 2)
      a[i].opt = 1;
    else
      a[i].opt = 2;
    a[i].id = i;
    if (mp.find(a[i].p - a[i].t) == mp.end()) mp[a[i].p - a[i].t] = ++cnt;
    v[mp[a[i].p - a[i].t]].push_back(a[i]);
    v2[mp[a[i].p - a[i].t]].push_back(a[i]);
  }
  for (long long i = 1; i <= cnt; i++) {
    sort(v[i].begin(), v[i].end(), [](QwQ x, QwQ y) {
      return x.opt != y.opt ? x.opt < y.opt
             : x.opt == 2   ? x.p < y.p
                            : x.p > y.p;
    });
    sort(v2[i].begin(), v2[i].end(), [](QwQ x, QwQ y) {
      return x.opt != y.opt ? x.opt > y.opt
             : x.opt == 2   ? x.p < y.p
                            : x.p > y.p;
    });
    for (long long j = 0; j < v[i].size(); j++) {
      if (v2[i][j].opt == 1)
        ans[v[i][j].id] = (node){w, v2[i][j].p};
      else
        ans[v[i][j].id] = (node){v2[i][j].p, h};
    }
  }
  for (long long i = 1; i <= n; i++) writeln(ans[i].x, ans[i].y);
  return 0;
}
