#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, W, H, pos[N], ti[N], gi[N], idx;
pair<int, int> ans[N];
map<int, int> id;
deque<int> dq[N];
vector<int> va[N], vb;
bool cmp(int x, int y) {
  if (pos[x] != pos[y]) return pos[x] < pos[y];
  return ti[x] < ti[y];
}
int main() {
  scanf("%d%d%d", &n, &W, &H);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &gi[i], &pos[i], &ti[i]);
    if (gi[i] == 1) {
      if (!id[ti[i] - pos[i]]) {
        id[ti[i] - pos[i]] = ++idx;
      }
      va[id[ti[i] - pos[i]]].push_back(i);
    } else {
      vb.push_back(i);
    }
  }
  for (int i = 1; i <= idx; ++i) {
    sort(va[i].begin(), va[i].end(), cmp);
    for (int j = 0; j < va[i].size(); ++j) dq[i].push_back(va[i][j]);
  }
  sort(vb.begin(), vb.end(), cmp);
  for (int i = 0; i < vb.size(); ++i) {
    int x = vb[i];
    int y = ti[x] - pos[x];
    if (!id[y]) {
      ans[x] = make_pair(W, pos[x]);
    } else {
      y = id[y];
      ans[dq[y].back()] = make_pair(W, pos[x]);
      dq[y].pop_back();
      dq[y].push_front(x);
    }
  }
  for (auto it = id.begin(); it != id.end(); ++it) {
    int a = it->second;
    int j = 0;
    for (auto jt = dq[a].begin(); jt != dq[a].end(); ++jt, ++j) {
      ans[*jt] = make_pair(pos[va[a][j]], H);
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d %d\n", ans[i].first, ans[i].second);
  return 0;
}
