class DSU: def __init__(self, n): self._n = n self.parent_or_size = [-1] * n def merge(self, a, b): assert 0 <= a < self._n assert 0 <= b < self._n x, y = self.leader(a), self.leader(b) if x == y: return x if -self.parent_or_size[x] < -self.parent_or_size[y]: x, y = y, x self.parent_or_size[x] += self.parent_or_size[y] self.parent_or_size[y] = x return x def same(self, a, b): assert 0 <= a < self._n assert 0 <= b < self._n return self.leader(a) == self.leader(b) def leader(self, a): assert 0 <= a < self._n if self.parent_or_size[a] < 0: return a self.parent_or_size[a] = self.leader(self.parent_or_size[a]) return self.parent_or_size[a] def size(self, a): assert 0 <= a < self._n return -self.parent_or_size[self.leader(a)] def groups(self): leader_buf = [self.leader(i) for i in range(self._n)] result = [[] for _ in range(self._n)] for i in range(self._n): result[leader_buf[i]].append(i) return [r for r in result if r != []] H, W, N, D = map(int, input().split()) A = [[-1] * W for _ in range(H)] for i in range(N): h, w = map(int, input().split()) h -= 1; w -= 1 A[h][w] = i B = [] for i in range(-D, D + 1): for j in range(-D, D + 1): if abs(i) + abs(j) > D: continue if i == 0 and j == 0: continue B.append((i, j)) uf = DSU(N) for i in range(H): for j in range(W): if A[i][j] == -1: continue for di, dj in B: ni = i + di nj = j + dj if 0 > ni or ni >= H or 0 > nj or nj >= W or A[ni][nj] == -1: continue uf.merge(A[i][j], A[ni][nj]) cnt = 0 for g in uf.groups(): if len(g) >= 2: cnt += 1 ans = [] for i in range(H): for j in range(W): if A[i][j] != -1: continue DD, EE = set(), set() for di, dj in B: ni = i + di nj = j + dj if 0 > ni or ni >= H or 0 > nj or nj >= W or A[ni][nj] == -1: continue ld = uf.leader(A[ni][nj]) if uf.size(ld) == 1: EE.add(ld) else: DD.add(ld) if len(EE) == 0: if len(DD) == 0: ans.append(cnt) else: ans.append(cnt - len(DD) + 1) else: ans.append(cnt - len(DD) + 1) print(min(ans), max(ans))