#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int h, w, n, d; cin >> h >> w >> n >> d; vector> stars(h, vector(w, 0)); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; stars[x - 1][y - 1] = -1; } int cur = 1, su = 0; auto is_in = [&](int x, int y) { return x >= 0 && x < h && y >= 0 && y < w; }; vector is_single{false}; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (!stars[i][j] || stars[i][j] != -1) { continue; } stars[i][j] = cur; deque> q{{i, j}}; int cnt = 0; while (!q.empty()) { auto [x, y] = q.front(); q.pop_front(); cnt++; for (int k = 1; k <= d; k++) { for (int di = -k; di <= k; di++) { for (int dj = -k; dj <= k; dj++) { if (abs(di) + abs(dj) > k) { continue; } if (!is_in(x + di, y + dj)) { continue; } if (stars[x + di][y + dj] == -1) { stars[x + di][y + dj] = cur; q.push_back({x + di, y + dj}); } } } } } cur++; is_single.push_back(cnt == 1); if (cnt != 1) { su++; } } } int mi = 1e9, ma = -1; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (stars[i][j]) { continue; } set conn; for (int k = 1; k <= d; k++) { for (int di = -k; di <= k; di++) { for (int dj = -k; dj <= k; dj++) { if (abs(di) + abs(dj) > k) { continue; } if (!is_in(i + di, j + dj)) { continue; } if (stars[i + di][j + dj]) { conn.insert(stars[i + di][j + dj]); } } } } int tmp = su + 1; for (int c : conn) { if (!is_single[c]) { tmp--; } } if (conn.size() == 0) { tmp--; } mi = min(mi, tmp); ma = max(ma, tmp); } } cout << mi << " " << ma << endl; }