def root(x): if P[x] < 0: return x P[x] = root(P[x]) # 経路圧縮 return P[x] def unite(x,y): x = root(x) y = root(y) if x == y: return if x > y: x,y = y,x P[x] += P[y] P[y] = x def same(x,y): return root(x) == root(y) def size(x): x = root(x) return -P[x] H, W, N, D = map(int, input().split()) XY = [tuple(map(int,input().split())) for _ in range(N)] XYS = set(XY) P = [-1] * N dic = {} for i in range(N): dic[tuple(XY[i])] = i def search(x, y): ret = set() for i in range(-D, D+1): if 0 < x + i <= H: xi = x + i for j in range(-D + abs(i), D - abs(i) + 1): if 0 < y + j <= W: yj = y+j if (xi,yj) in dic: ret.add(dic[(xi,yj)]) return ret for i,(x,y) in enumerate(XY): for j in search(x,y): unite(i,j) Q = set() for i in range(N): if size(i) >= 2: Q.add(root(i)) gcount = len(Q) ansmax = 0 ansmin = gcount for i in range(1,H+1): for j in range(1,W+1): if (i,j) in XY: continue tmp = search(i,j) Q1 = set() Q2 = set() for k in tmp: if size(k) > 1: Q2.add(root(k)) else: Q1.add(k) if Q2: tmp2 = gcount - len(Q2) + 1 ansmax = max(ansmax, tmp2) ansmin = min(ansmin, tmp2) elif Q1: tmp2 = gcount + 1 ansmax = max(ansmax,tmp2) ansmin = min(ansmin,tmp2) print(ansmin,ansmax)