#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n;
if (!(cin >> n)) return;
vector<pair<int, int>> arr(n);
vector<int> res(2 * n, 0);
for (int i = 0; i < n; i++) {
cin >> arr[i].first >> arr[i].second;
// Her telin toplamını (mod 2N) hesapla
int sum = (arr[i].first + arr[i].second) % (2 * n);
res[sum]++;
}
// Sadece TEK olan toplamlar (M) geçerlidir
int mx = -1, mxi = 1;
for (int i = 1; i < 2 * n; i += 2) {
if (res[i] > mx) {
mx = res[i];
mxi = i;
}
}
// Minimum adım sayısı: Halihazırda doğru olmayan teller
cout << n - mx << "\n";
for (int i = 0; i < n; i++) {
int current_sum = (arr[i].first + arr[i].second) % (2 * n);
if (current_sum != mxi) {
// Hedef pin: (M - current_pin) mod 2N
// Birinci ucu sabit tutup ikinci ucu taşıyoruz
int start_pin = arr[i].first;
int old_end = arr[i].second;
int new_end = (mxi - start_pin + 2 * n) % (2 * n);
cout << i << " " << old_end << " " << new_end << "\n";
}
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}