import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): group_members = collections.defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return ''.join(f'{r}: {m}' for r, m in self.all_group_members().items()) #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) input = sys.stdin.readline #n = int(input()) #alist = list(map(int,input().split())) #alist = [] #s = input() h,w,n,d = map(int,input().split()) #for i in range(n): # alist.append(list(map(int,input().split()))) dxy = [] for x in range(-5,6): for y in range(-5,6): if 1 <= abs(x) + abs(y) <= d: dxy.append((x,y)) s = set() c = collections.defaultdict(int) l = [] for i in range(n): x,y =map(int,input().split()) x -= 1 y -= 1 s.add((x,y)) l.append((x,y)) c[(x,y)] = i uf = UnionFind(n) for i in range(n): x,y = l[i] for dx,dy in dxy: if (x+dx,y+dy) in s: uf.union(i,c[(x+dx,y+dy)]) mi,ma = 10**18,-10**18 res = 0 for i in range(n): if uf.find(i) == i and uf.size(i) >= 2: res += 1 for i in range(h): for j in range(w): if (i,j) in s: continue se = set() now = res cnt = 0 for dx,dy in dxy: if (i+dx,j+dy) in s and uf.find(c[i+dx,j+dy]) not in se: se.add(uf.find(c[i+dx,j+dy])) if cnt == 0: cnt += 1 if uf.size(c[i+dx,j+dy]) == 1: now += 1 else: if uf.size(c[i+dx,j+dy]) >= 2: now -= 1 mi = min(mi,now) ma = max(ma,now) #print(i,j,res,se) print(mi,ma)