## https://yukicoder.me/problems/no/2696 from collections import deque def main(): H, W, N, D = map(int, input().split()) xy = [] for _ in range(N): x, y = map(int, input().split()) xy.append((x - 1, y -1)) # 座標から星idを取れるようにする star_map = {} for i in range(N): x, y = xy[i] star_map[(x, y)] = i # 連結成分ごとに分ける components_list = [-1] * N component_id = 0 for s in range(N): if components_list[s] == -1: queue = deque() queue.append(s) components_list[s] = component_id while len(queue) > 0: v = queue.popleft() h, w = xy[v] for di in range(-5, 6): for dj in range(-5, 6): if abs(di) + abs(dj) > D: continue if di == 0 and dj == 0: continue new_h = h + di new_w = w + dj if 0 <= new_h < H and 0 <= new_w < W: if (new_h, new_w) in star_map: new_v = star_map[(new_h, new_w)] if components_list[new_v] == -1: components_list[new_v] = component_id queue.append(new_v) component_id += 1 # 星の集合の中にどれくらい星があるかを入れる component_id_map = {} for i in range(N): c_id = components_list[i] if c_id not in component_id_map: component_id_map[c_id] = 0 component_id_map[c_id] += 1 base_size = 0 for key, volume in component_id_map.items(): if volume > 1: base_size += 1 min_size = base_size max_size = base_size # それぞれの座標に星を置いた時の調査 for h in range(H): for w in range(W): if (h, w) in star_map: continue seiza_set = set() b = set() for di in range(-5, 6): for dj in range(-5, 6): if abs(di) + abs(dj) > D: continue if di == 0 and dj == 0: continue new_h = h + di new_w = w + dj if 0 <= new_h < H and 0 <= new_w < W: if (new_h, new_w) in star_map: i = star_map[(new_h, new_w)] x = components_list[i] if component_id_map[x] == 1: b.add(x) else: seiza_set.add(x) ans = 0 if len(seiza_set) > 0: ans = 1 - len(seiza_set) elif len(b) > 0: ans = 1 min_size = min(min_size, base_size + ans) max_size = max(max_size, base_size + ans) print(min_size, max_size) if __name__ == "__main__": main()