#include using namespace std; int main(){ int H, W, N, D; cin >> H >> W >> N >> D; vector X(N), Y(N); for (int i = 0; i < N; i++){ cin >> X[i] >> Y[i]; X[i]--; Y[i]--; } vector> idx(H, vector(W, -1)); for (int i = 0; i < N; i++){ idx[X[i]][Y[i]] = i; } vector C(N, -1); int cnt = 0; vector VC; int cnt2 = 0; for (int i = 0; i < N; i++){ if (C[i] == -1){ C[i] = cnt; queue Q; Q.push(i); int V = 0; while (!Q.empty()){ int v = Q.front(); Q.pop(); V++; for (int dx = -D; dx <= D; dx++){ for (int dy = -(D - abs(dx)); dy <= D - abs(dx); dy++){ int x = X[v] + dx; int y = Y[v] + dy; if (0 <= x && x < H && 0 <= y && y < W){ if (idx[x][y] != -1){ if (C[idx[x][y]] == -1){ C[idx[x][y]] = cnt; Q.push(idx[x][y]); } } } } } } VC.push_back(V); if (V >= 2){ cnt2++; } cnt++; } } int mn = N + 1, mx = 0; for (int i = 0; i < H; i++){ for (int j = 0; j < W; j++){ if (idx[i][j] == -1){ set st; for (int dx = -D; dx <= D; dx++){ for (int dy = -(D - abs(dx)); dy <= D - abs(dx); dx++){ int x = i + dx; int y = j + dy; if (0 <= x && x < H && 0 <= y && y < W){ if (idx[x][y] != -1){ st.insert(C[idx[x][y]]); } } } } if (!st.empty()){ int tmp = cnt2; for (int x : st){ if (VC[x] >= 2){ tmp--; } } tmp++; mn = min(mn, tmp); mx = max(mx, tmp); } else { mn = min(mn, cnt2); mx = max(mx, cnt2); } } } } cout << mn << ' ' << mx << endl; }