#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
const int maxm = 100000 + 10;
const int mod = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 60);
const double PI = acos(-1.0);
struct node {
  int x, y, id;
  node() {}
  bool operator<(const node &r) const { return x < r.x || x == r.x && y > r.y; }
};
vector<node> a[maxn << 1];
node goal[maxn];
pair<int, int> ans[maxn];
int main() {
  int n, w, h;
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 1; i <= n; i++) {
    int g, p, t;
    scanf("%d%d%d", &g, &p, &t);
    node robot;
    robot.id = i;
    if (g == 1) {
      robot.x = p;
      robot.y = 0;
    } else {
      robot.x = 0;
      robot.y = p;
    }
    a[p - t + (int)1e5].push_back(robot);
  }
  for (int i = 0; i <= (int)2e5; i++) {
    int sz = a[i].size();
    if (sz) {
      sort(a[i].begin(), a[i].end());
      for (int j = 0; j < sz; j++) {
        node &k = a[i][j];
        if (k.x) {
          goal[j].x = k.x;
          goal[j].y = h;
        } else {
          goal[j].x = w;
          goal[j].y = k.y;
        }
      }
      sort(goal, goal + sz);
      for (int j = 0; j < sz; j++) {
        node &k = a[i][j];
        ans[k.id].first = goal[j].x;
        ans[k.id].second = goal[j].y;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
