//
// Created by tamas on 9/7/23.
//
// sztem kicsit ronda, de hát na
#include "bits/stdc++.h"
using namespace std;
#define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define ull unsigned long long
int N;
ull top, bot, T;
struct coord {
ull first;
ull second;
int index;
};
vector<coord> by_x;
vector<coord> by_y;
vector<bool> visited;
vector<coord> tornyok;
auto sort_by_x = [](coord a, coord b) {
if (a.first == b.first)
return a.second > b.second;
return a.first < b.first;
};
auto sort_by_y = [](coord a, coord b) {
if (a.second == b.second)
return a.first > b.first;
return a.second > b.second;
};
void dfs(coord& x) {
// cout << "in " << x.first << " " << x.second << "\n";
visited[x.index] = true;
long ind = std::lower_bound(by_x.begin(), by_x.end(), x, sort_by_x) - by_x.begin();
long i = ind-1;
while (i >= 0 && by_x[i].first == x.first && by_x[i].second - x.second <= T) {
if (!visited[by_x[i].index]) {
dfs(by_x[i]);
}
i--;
}
i = ind+1;
while (i < N && by_x[i].first == x.first && x.second - by_x[i].second <= T) {
if (!visited[by_x[i].index]) {
dfs(by_x[i]);
}
i++;
}
ind = std::lower_bound(by_y.begin(), by_y.end(), x, sort_by_y) - by_y.begin();
i = ind-1;
while (i >= 0 && by_y[i].second == x.second && by_y[i].first - x.first <= T) {
if (!visited[by_y[i].index]) {
dfs(by_y[i]);
}
i++;
}
i = ind+1;
while (i < N && by_y[i].second == x.second && x.first - by_y[i].first <= T ) {
if (!visited[by_y[i].index]) {
dfs(by_y[i]);
}
i--;
}
}
inline bool good() {
for (auto kv : visited) {
kv = false;
}
// cout << "T=" << T << ":\n";
dfs(by_x[0]);
for (auto p : visited)
if (!p)
return false;
return true;
}
inline int gut() {
for (auto kv : visited) {
kv = false;
}
// cout << "T=" << T << ":\n";
int r = -1;
T--;
for (int i = 0; i < N; i++)
if (!visited[i]) {
r++;
dfs((coord &) tornyok[i]);
}
T++;
return r;
}
int main() {
InTheNameOfGod
cin >> N;
by_y.reserve(N);
by_x.reserve(N);
visited.assign(N, false);
tornyok.resize(N);
for (int i = 0; i < N; i++) {
ull x, y;
cin >> x >> y;
x--; y--;
coord c = (coord) {
.first = x,
.second = y,
.index = i
};
tornyok[i] = c;
by_x.emplace_back(c);
by_y.emplace_back(c);
}
std::sort(by_y.begin(), by_y.end(), sort_by_y);
std::sort(by_x.begin(), by_x.end(), sort_by_x);
bot = 1;
top = 10'000'001;
T = (top/N);
while (bot <= top) {
if (good())
top = T - 1;
else
bot = T + 1;
T = (bot + top) / 2;
}
T++; // idk miért
cout << T << "\n" << gut();
}