#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
vector<pair<int, pair<int, int> > > points;
map<int, int> M;
vector<int> actual[N << 2];
vector<int> mirror[N << 2];
bool cmp1(int i, int j) {
  pair<int, pair<int, int> > a = points[i];
  pair<int, pair<int, int> > b = points[j];
  if (a.first != b.first) {
    return a.first > b.first;
  } else if (a.first == 1) {
    return a.second.first < b.second.first;
  } else {
    return a.second.first > b.second.first;
  }
}
bool cmp2(int i, int j) {
  pair<int, pair<int, int> > a = points[i];
  pair<int, pair<int, int> > b = points[j];
  if (a.first != b.first) {
    return a.first < b.first;
  } else if (a.first == 1) {
    return a.second.first < b.second.first;
  } else {
    return a.second.first > b.second.first;
  }
}
int main() {
  int n, w, h;
  scanf("%d%d%d", &n, &w, &h);
  for (int i = 0; i < n; i++) {
    int gi, pi, ti;
    scanf("%d%d%d", &gi, &pi, &ti);
    points.push_back(make_pair(gi, make_pair(pi, ti)));
  }
  for (int i = 0; i < n; i++) {
    if (points[i].first == 1) {
      int hsh = points[i].second.first - points[i].second.second + N;
      actual[hsh].push_back(i);
    } else {
      int hsh = points[i].second.first - points[i].second.second + N;
      mirror[hsh].push_back(i);
    }
  }
  for (int i = 0; i < n; i++) {
    if (points[i].first != 1) {
      int hsh = points[i].second.first - points[i].second.second + N;
      actual[hsh].push_back(i);
    } else {
      int hsh = points[i].second.first - points[i].second.second + N;
      mirror[hsh].push_back(i);
    }
  }
  for (int i = 0; i < (N << 2); i++) {
    assert(actual[i].size() == mirror[i].size());
    sort(actual[i].begin(), actual[i].end(), cmp1);
    sort(mirror[i].begin(), mirror[i].end(), cmp2);
    for (int j = 0; j < actual[i].size(); j++) {
      M[actual[i][j]] = mirror[i][j];
    }
  }
  assert(n == points.size());
  for (int i = 0; i < n; i++) {
    int rev = M[i];
    if (points[rev].first == 1) {
      printf("%d %d\n", points[rev].second.first, h);
    } else {
      printf("%d %d\n", w, points[rev].second.first);
    }
  }
  return 0;
}
