#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
int n, w, h;
int g[maxn], p[maxn], t[maxn], ansx[maxn], ansy[maxn];
vector<int> s[maxn * 2], xs, ys;
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &g[i], &p[i], &t[i]);
    s[p[i] - t[i] + maxn].push_back(i);
  }
  for (int i = 0; i < 2 * maxn; i++) {
    if (s[i].empty()) continue;
    for (int u : s[i]) {
      if (g[u] == 1)
        xs.push_back(p[u]);
      else
        ys.push_back(p[u]);
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    sort(s[i].begin(), s[i].end(), [](int u, int v) {
      if (g[u] != g[v]) return (g[u] == 2);
      return g[u] == 2 ? p[u] > p[v] : p[u] < p[v];
    });
    for (int j = 0; j < xs.size(); j++) {
      ansx[s[i][j]] = xs[j];
      ansy[s[i][j]] = h;
    }
    for (int j = 0; j < ys.size(); j++) {
      ansx[s[i][j + xs.size()]] = w;
      ansy[s[i][j + xs.size()]] = ys[ys.size() - j - 1];
    }
    xs.clear();
    ys.clear();
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", ansx[i], ansy[i]);
  return 0;
}
