import sys input = lambda: sys.stdin.readline().rstrip() from collections import defaultdict class UnionFind: def __init__(self, N): self.N = N self.parent_or_size = [-1] * N self.group_count = N def root(self, x): if self.parent_or_size[x] < 0: return x else: self.parent_or_size[x] = self.root(self.parent_or_size[x]) return self.parent_or_size[x] def unite(self, x, y): root_x = self.root(x) root_y = self.root(y) if root_x == root_y: return if -self.parent_or_size[root_x] < -self.parent_or_size[root_y]: root_x, root_y = root_y, root_x self.parent_or_size[root_x] += self.parent_or_size[root_y] self.parent_or_size[root_y] = root_x self.group_count -= 1 def same(self, x, y): return self.root(x) == self.root(y) def size(self, x): return -self.parent_or_size[self.root(x)] def groups(self): ret = defaultdict(list) for i in range(self.N): ret[self.root(i)].append(i) return [group for group in ret.values()] input = lambda: sys.stdin.readline().rstrip() SHIFT = 20 MASK = (1 << SHIFT) - 1 def conv(x, y): return x << SHIFT | y def rev(pos): return pos >> SHIFT, pos & MASK H, W, N, D = map(int, input().split()) star = {} XY = [] for i in range(N): x, y = map(int, input().split()) x -= 1 y -= 1 XY.append((x, y)) star[conv(x, y)] = i MOVES = [] for xd in range(-D, D + 1): for yd in range(-D, D + 1): d = abs(xd) + abs(yd) if d > D: continue MOVES.append((xd, yd)) uf = UnionFind(N) for i, (x, y) in enumerate(XY): for xd, yd in MOVES: d = abs(xd) + abs(yd) if d > D: continue xn = x + xd yn = y + yd if not (0 <= xn < H and 0 <= yn < W): continue posn = conv(xn, yn) if posn in star: uf.unite(i, star[posn]) stella = uf.groups() is_seiza = [0] * N count = 0 for block in stella: if len(block) > 1: count += 1 for i in block: is_seiza[i] = 1 mi = N ma = 0 for x in range(H): for y in range(W): if conv(x, y) in star: continue seen = set() flag = False for xd, yd in MOVES: d = abs(xd) + abs(yd) if d > D: continue xn = x + xd yn = y + yd posn = conv(xn, yn) if posn not in star: continue j = uf.root(star[posn]) if is_seiza[j]: seen.add(j) else: flag = True if seen: c = count - (len(seen) - 1) elif flag: c = count + 1 else: c = count mi = min(mi, c) ma = max(ma, c) print(mi, ma)