#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { const auto start = steady_clock::now(); std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int64_t n; cin >> n; vector as(n), bs(n); for (int64_t i = 0; i < n; i++) { cin >> as[i] >> bs[i]; } random_device rnd; mt19937 engine(rnd()); uniform_int_distribution<> randt(0, 45); uniform_int_distribution<> randn(0, n - 1); int64_t c = 500000000000000000LL; auto calc_score = [&] { return int64_t(2000000 - 100000 * log10(max(abs(as[0] - c), abs(bs[0] - c)) + 1)); }; vector us, vs; for (int64_t t = 0; t < 50; t++) { if (t % 2 == 0) { int64_t p = 1, q = 2; if (t != 49 && t < 2 * randt(engine)) { p = randn(engine); do { q = randn(engine); } while (p == q); } else { for (int64_t i = 1; i < n; i++) { for (int64_t j = i + 1; j < n; j++) { int64_t x = (as[i] + as[j]) / 2; int64_t y = (bs[i] + bs[j]) / 2; int64_t a = (as[p] + as[q]) / 2; int64_t b = (bs[p] + bs[q]) / 2; if (max(abs(as[0] + x) / 2 - c, abs(bs[0] + y) / 2 - c) < max(abs(as[0] + a) / 2 - c, abs(bs[0] + b) / 2 - c)) { p = i; q = j; } } } } int64_t x = (as[p] + as[q]) / 2; int64_t y = (bs[p] + bs[q]) / 2; as[p] = as[q] = x; bs[p] = bs[q] = y; us.push_back(p + 1); vs.push_back(q + 1); } else { int64_t i = 1; for (int64_t j = 2; j < n; j++) { if (max(abs((as[0] + as[j]) / 2 - c), abs((bs[0] + bs[j]) / 2 - c)) < max(abs((as[0] + as[i]) / 2 - c), abs((bs[0] + bs[i]) / 2 - c))) { i = j; } } int64_t x = (as[0] + as[i]) / 2; int64_t y = (bs[0] + bs[i]) / 2; as[0] = as[i] = x; bs[0] = bs[i] = y; us.push_back(1); vs.push_back(i + 1); } } cout << us.size() << '\n'; for (int64_t i = 0; i < us.size(); i++) { cout << us[i] << ' ' << vs[i] << '\n'; } cerr << calc_score() << endl; for (int64_t i = 0; i < n; i++) { cerr << as[i] << ' ' << bs[i] << endl; } return 0; }