#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
int test;
int n, w, h;
unordered_map<int, list<pair<int, int>>> m;
unordered_map<int, vector<int>> vals;
unordered_map<int, list<int>> ids;
vector<pair<int, int>> iksy[200007];
pair<int, int> res[200007];
void solve() {
  cin >> n >> w >> h;
  for (int i = 1; i <= (n); ++i) {
    int x, y, t;
    cin >> x >> y >> t;
    if (x == 1) {
      x = y;
      y = 0;
    } else if (x == 2) {
      x = 0;
    }
    if (y > 0) {
      m[t - y].emplace_back(y, i);
    } else {
      iksy[x].emplace_back(t, i);
    }
  }
  for (auto it : m) {
    m[it.first].sort();
    for (auto it1 : m[it.first]) {
      vals[it.first].push_back(it1.first);
      ids[it.first].push_back(it1.second);
    }
  }
  for (int i = 1; i <= (100 * 1000); ++i) {
    for (auto it1 : iksy[i]) {
      int val = it1.first - i;
      if (ids[val].size() == 0) {
        res[it1.second] = make_pair(i, h);
      } else {
        auto it = ids[val].back();
        res[it] = make_pair(i, h);
        ids[val].emplace_front(it1.second);
        ids[val].pop_back();
      }
    }
  }
  for (auto it : m) {
    int i = 0;
    for (auto it1 : ids[it.first]) {
      res[it1] = make_pair(w, vals[it.first][i]);
      i++;
    }
  }
  for (int i = 1; i <= (n); ++i) {
    cout << res[i].first << " " << res[i].second << '\n';
  }
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;
  test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
