#include <algorithm>
#include <cstdio>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;
int main (int argc, char *argv[]) {
int n;
cin >> n;
vector<tuple<int, int, int>> legos(n);
for (int i = 0; i < n; i++) {
int uolevi, maija;
cin >> uolevi >> maija;
legos[i] = make_tuple(uolevi - maija, uolevi, maija);
}
sort(legos.begin(), legos.end());
for (int i = 0; i < n; i++) {
cout << get<0>(legos[i]) << " ";
cout << get<1>(legos[i]) << " ";
cout << get<2>(legos[i]) << " \n";
}
int uolevi_sum = 0;
int maija_sum = 0;
int half_way = n % 2 == 0 ? n / 2 : n / 2 + 1;
for (int i = 0; i < half_way; i++) {
maija_sum
}
cout << "\n";
return 0;
}