#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int maxn = 2e5 + 5;
struct node {
  int idx, p;
  bool operator<(const node &b) const { return p < b.p; }
} ver[100005], hor[100005];
int vcnt, hcnt;
vector<node> V1[maxn], V2[maxn];
int tempx[100005], tempy[100005];
int ansx[100005], ansy[100005];
int main() {
  int n, w, h;
  cin >> n >> w >> h;
  int g, p, t;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &g);
    if (g == 1) {
      vcnt++;
      scanf("%d%d", &p, &t);
      V1[p - t + 100000].push_back({i, p});
    } else {
      hcnt++;
      scanf("%d%d", &p, &t);
      V2[p - t + 100000].push_back({i, p});
    }
  }
  for (int i = 0; i < maxn; i++) {
    sort(V1[i].begin(), V1[i].end());
    sort(V2[i].begin(), V2[i].end());
  }
  for (int i = 0; i < maxn; i++) {
    int cnt = 0;
    for (int j = 0; j < V1[i].size(); j++) {
      tempx[cnt] = V1[i][j].p;
      tempy[cnt] = h;
      cnt++;
    }
    for (int j = V2[i].size() - 1; j >= 0; j--) {
      tempx[cnt] = w;
      tempy[cnt] = V2[i][j].p;
      cnt++;
    }
    cnt = 0;
    for (int j = V2[i].size() - 1; j >= 0; j--) {
      ansx[V2[i][j].idx] = tempx[cnt];
      ansy[V2[i][j].idx] = tempy[cnt];
      cnt++;
    }
    for (int j = 0; j < V1[i].size(); j++) {
      ansx[V1[i][j].idx] = tempx[cnt];
      ansy[V1[i][j].idx] = tempy[cnt];
      cnt++;
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d %d\n", ansx[i], ansy[i]);
  }
  return 0;
}
