#include <bits/stdc++.h>
using namespace std;
int Y[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int X[] = {0, 0, -1, 1, -1, 1, -1, 1};
int directions = 4;
long long power(long long a, long long n) {
  if (a == 0) return 0;
  if (a == 1 || n == 0) return 1;
  if (n == 1) return a % 1000000007;
  long long t = power(a, n / 2);
  t = t * t % 1000000007;
  if (n & 1) return t * a % 1000000007;
  return t;
}
void keywords() {
  return;
  int x;
  scanf("%d", &x);
  printf("lol");
  cin >> x;
  cout << "lol" << endl;
  while (1) continue;
  while (1) break;
}
int popcount(long long a) {
  int c = 0;
  while (a) {
    c++;
    a -= a & -a;
  }
  return c;
}
void factorize(int a) {}
void update(int tree[], int idx, int val, int maxval) {
  for (; idx <= maxval; idx += idx & -idx) {
    tree[idx] += val;
  }
}
int read(int tree[], int idx) {
  long long sum = 0;
  for (; idx > 0; idx -= idx & -idx) {
    sum += tree[idx];
  }
  return sum;
}
struct node2 {
  int id, val;
  node2() {
    static int ctx = 1;
    id = ctx++;
  };
  node2(int a, int b = 0, int c = 0, int d = 0, int e = 0, int f = 0) {
    val = a;
  }
};
struct comp2 {
  bool operator()(int a, int b) { return b < a; }
};
struct node {
  int id, x, y;
  node(){};
  node(int a, int b = 0, int c = 0, int d = 0, int e = 0, int f = 0) {}
};
struct comp {
  bool operator()(int a, int b) { return b < a; }
};
bool cmp(pair<node, int> a, pair<node, int> b) {
  if (a.second == b.second) return a.first.x < b.first.x;
  return a.second < b.second;
}
int n, m, a, b, c, d, k, h, w, x, y, q, t, res, ma, mi, T,
    act = 0, pas = 1, cur, flag, now, off = 100000;
int uu, vv, ww, l, r;
int dp, dp2, cnt;
char s[1];
pair<int, int> ans[100009];
node p;
vector<pair<node, int> > line[2 * 100009];
double f, z, e;
vector<int> v, vec;
set<int> sett;
map<int, int> mapp;
void print() {}
void print2() {}
void input() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    cin >> c;
    p.id = i + 1;
    if (c == 1) {
      cin >> p.y;
      cin >> t;
      p.x = -t;
    }
    if (c == 2) {
      cin >> p.x;
      cin >> t;
      p.y = -t;
    }
    line[p.y + p.x + off].push_back(make_pair(p, c));
  }
}
inline void calc(vector<pair<node, int> >& line) {
  int k = 0;
  for (int i = 0; i < line.size(); i++) {
    if (line[i].second == 2) {
      k = i;
      break;
    }
  }
  for (int i = 0; i < line.size(); i++) {
    ans[line[i].first.id].second = (line[k].second == 2 ? line[k].first.x : h);
    ans[line[i].first.id].first = (line[k].second == 2 ? w : line[k].first.y);
    k++;
    k %= line.size();
  }
}
void solve() {
  int lim = 100000;
  for (int i = -lim; i < lim + 1; i++) {
    if (line[i + off].empty()) continue;
    sort(line[i + off].begin(), line[i + off].end(), cmp);
    calc(line[i + off]);
  }
}
void output() {
  for (int i = 1; i < n + 1; i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
int main() {
  input();
  solve();
  output();
  return 0;
}
