#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } struct UndoUnionFind{ int n; vector par; vector> history; explicit UndoUnionFind(int v): n(v), par(v,-1) {} void merge(int a, int b){ int x = find(a); int y = find(b); history.push_back(pair(x, par[x])); history.push_back(pair(y, par[y])); if (x == y) return; if (-par[x] < -par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return; } int find(int x){ if (par[x] < 0) return x; return find(par[x]); } void undo(){ par[history.back().first] = history.back().second; history.pop_back(); par[history.back().first] = history.back().second; history.pop_back(); return; }; }; int main(){ int h, w; cin >> h >> w; int n, d; cin >> n >> d; vector x(n), y(n); rep(i,0,n) cin >> x[i] >> y[i]; map,int> taio; rep(i,0,n){ taio[pair(x[i], y[i])] = i; } UndoUnionFind uf(n+1); int val = 0; rep(i,0,n){ rep(dx,-d,d+1){ rep(dy,-d,d+1){ if (abs(dx)+abs(dy)>d) continue; if (taio.find(pair(x[i]+dx,y[i]+dy)) == taio.end()){ continue; } if (uf.find(taio[pair(x[i]+dx,y[i]+dy)]) != uf.find(i)){ if (-uf.par[uf.find(taio[pair(x[i]+dx,y[i]+dy)])] >= 2){ val--; } if (-uf.par[uf.find(i)] >= 2){ val--; } uf.merge(taio[pair(x[i]+dx,y[i]+dy)], i); if(-uf.par[uf.find(i)]>=2){ val++; } } } } } int mn = 1e9; int mx = -1; rep(i,1,h+1){ rep(j,1,w+1){ if (taio.find(pair(i,j)) != taio.end()){ continue; } int cnt = 0; int orval = val; rep(dx,-d,d+1){ rep(dy,-d,d+1){ if (abs(dx)+abs(dy) > d) continue; if (taio.find(pair(i+dx, j+dy)) == taio.end()){ continue; } if (uf.find(taio[pair(i+dx, j+dy)]) != uf.find(n)){ if (-uf.par[uf.find(taio[pair(i+dx, j+dy)])] >= 2){ val--; } if( -uf.par[uf.find(n)] >= 2){ val--; } uf.merge(taio[pair(i+dx, j+dy)], n); if( -uf.par[uf.find(n)] >= 2){ val++; } cnt++; } } } chmax(mx,val); chmin(mn,val); rep(num,0,cnt){ uf.undo(); } val = orval; } } cout << mn << ' ' << mx << '\n'; }