from bisect import bisect_left, bisect_right class UnionFind: def __init__(self,n): self.n = n self.parent_size = [-1]*n def leader(self,a): if self.parent_size[a] < 0: return a self.parent_size[a] = self.leader(self.parent_size[a]) return self.parent_size[a] def merge(self,a,b): x, y = self.leader(a), self.leader(b) if x == y: return if abs(self.parent_size[x]) < abs(self.parent_size[y]): x, y = y, x self.parent_size[x] += self.parent_size[y] self.parent_size[y] = x return def same(self,a,b): return self.leader(a) == self.leader(b) def size(self,a): return abs(self.parent_size[self.leader(a)]) def groups(self): result = [[] for _ in range(self.n)] for i in range(self.n): result[self.leader(i)].append(i) return [r for r in result if r != []] H, W, N, D = map(int, input().split()) XY = [list(map(int, input().split())) for _ in range(N)] idx = dict() xyD = dict() for i in range(N): X, Y = XY[i] idx[(X, Y)] = i if X in xyD: xyD[X].append(Y) else: xyD[X] = [Y] for i in xyD.keys(): xyD[i].sort() UF = UnionFind(N) for i in range(N): X, Y = XY[i] for dx in range(D+1): for dy in range(-D, D+1): if abs(dx)+abs(dy) > D: continue nx, ny = X+dx, Y+dy if (nx, ny) in idx: UF.merge(i, idx[(nx, ny)]) def func(x, y): S = set() for dx in range(-D, D+1): nx = x+dx if nx not in xyD: continue left = y-(D-abs(dx)) right = y+(D-abs(dx)) lb = bisect_left(xyD[nx], left) rb = bisect_right(xyD[nx], right) for i in range(lb, rb): S.add(UF.leader(idx[(nx, xyD[nx][i])])) if len(S) == 0: return L else: cnt = dict() for s in S: if UF.size(s) in cnt: cnt[UF.size(s)] += 1 else: cnt[UF.size(s)] = 1 if 1 in cnt: cnt.pop(1) c = sum(i for i in cnt.values()) return L+1-c INF = 10**18 ansMIN = INF ansMAX = -INF L = sum(len(g) >= 2 for g in UF.groups()) for x in range(1, H+1): for y in range(1, W+1): if (x, y) in idx: continue cnt = func(x, y) ansMIN = min(ansMIN, cnt) ansMAX = max(ansMAX, cnt) print(ansMIN, ansMAX)