class unif: def __init__(self,n): self.pare=[-1]*n self.size=[1]*n def root(self,x): while self.pare[x]!=-1: x=self.pare[x] return x def unite(self,u,v): rootu=self.root(u) rootv=self.root(v) if rootu!=rootv: if self.size[rootu]>=self.size[rootv]: self.pare[rootv]=rootu self.size[rootu]+=self.size[rootv] else: self.pare[rootu]=rootv self.size[rootv]+=self.size[rootu] def same(self,s,t): return self.root(s)==self.root(t) H,W,N,D=map(int,input().split()) C=set() A=[set() for i in range(H+1)] T={} L=[] for i in range(N): x,y=map(int,input().split()) L.append((x,y)) T[x*10**10+y]=i Z=unif(N) for i in range(N): x,y=L[i][:] for dx in range(-D,D+1): k=D-abs(dx) for dy in range(-k,k+1): x2,y2=x+dx,y+dy if x==x2 and y==y2: continue if x2<=0 or x2>=H+1 or y2<=0 or y2>=W+1: continue A[x2].add(y2) w=x2*10**10+y2 if w in T: pos=T[w] Z.unite(i,pos) count=0 b=set() for i in range(N): p=Z.root(i) if Z.size[p]>1: b.add(p) count=len(b) h=[] u=[0]*N t=[0]*N for i in range(N): p=Z.root(i) k=Z.size[p] u[i]=p t[i]=k ans1=10**10 ans2=-10**10 for x in range(1,H+1): if len(A[x])!=W: ans1=min(ans1,count) ans2=max(ans2,count) for y in A[x]: w=x*10**10+y if w in T: continue c=0 B=set() for dx in range(-D,D+1): k=D-abs(dx) for dy in range(-k,k+1): x2,y2=x+dx,y+dy if x==x2 and y==y2: continue if x2<=0 or x2>=H+1 or y2<=0 or y2>=W+1: continue w=x2*10**10+y2 if w in T: pos=T[w] if t[pos]==1: c=1 else: B.add(u[pos]) if c==1 and len(B)==0: r=1 else: r=1-len(B) ans1=min(ans1,r+count) ans2=max(ans2,r+count) print(ans1,ans2)