#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const double EPS = 1e-10;
const double PI = acos(-1);
const int MAX_N = (int)2e5;
struct Point {
  int x, y, id;
};
bool cmp(const Point& p1, const Point& p2) { return p1.x - p1.y < p2.x - p2.y; }
class Task {
 public:
  int N, H, W;
  unordered_map<int, vector<Point>> A, B;
  void solve(istream& in, ostream& out) {
    ios::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    in >> N >> W >> H;
    for (int(i) = (0); (i) < (N); ++(i)) {
      int g, x = 0, y = 0, t;
      in >> g;
      if (g == 1) {
        in >> x >> t;
        A[x - t].push_back({x, y, i});
        B[x - t].push_back({x, H, i});
      } else {
        in >> y >> t;
        A[y - t].push_back({x, y, i});
        B[y - t].push_back({W, y, i});
      }
    }
    vector<Point> ans(N);
    for (auto& u : A) {
      vector<Point>& v1 = u.second;
      vector<Point>& v2 = B[u.first];
      sort((v1).begin(), (v1).end(), cmp);
      sort((v2).begin(), (v2).end(), cmp);
      int sz = (int)(v1).size();
      for (int(j) = (0); (j) < (sz); ++(j)) {
        ans[v1[j].id] = v2[j];
      }
    }
    for (auto p : ans) {
      out << p.x << ' ' << p.y << '\n';
    }
  }
};
int main() {
  Task solver;
  istream& in(cin);
  ostream& out(cout);
  solver.solve(in, out);
  return 0;
}
