#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n, h, w, g[N], p[N], t[N], ansx[N], ansy[N];
vector<int> v[3 * N];
int main() {
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", g + i, p + i, t + i);
    v[p[i] - t[i] + N].push_back(i);
  }
  fill(ansx, ansx + N, w);
  fill(ansy, ansy + N, h);
  for (auto i : v)
    if (!i.empty()) {
      vector<int> x, y;
      for (auto j : i)
        if (g[j] == 2)
          y.push_back(p[j]);
        else
          x.push_back(p[j]);
      sort(x.rbegin(), x.rend());
      sort(y.begin(), y.end());
      sort(i.begin(), i.end(), [](int &a, int &b) {
        if (g[a] != g[b]) return g[a] == 1;
        if (g[a] == 1) return p[a] > p[b];
        return p[a] < p[b];
      });
      for (int j = 0; j < y.size(); j++) ansy[i[j]] = y[j];
      for (int j = 0; j < x.size(); j++) ansx[i[j + y.size()]] = x[j];
    }
  for (int i = 0; i < n; i++) printf("%d %d\n", ansx[i], ansy[i]);
}
