using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (h, w, n, d) = (c[0], c[1], c[2], c[3]); var map = NArr(n); var dic = new Dictionary(); var visited = new HashSet(); for (var i = 0; i < n; ++i) { var k = Key(map[i][0], map[i][1]); dic[k] = i; visited.Add(k); } var uf = new UnionFindTree(n); for (var i = 0; i < n; ++i) { var ix = map[i][0]; var iy = map[i][1]; foreach (var pos in Search(ix, iy, h, w, d)) { var pk = Key(pos.x, pos.y); if (dic.ContainsKey(pk)) uf.Unite(i, dic[pk]); } } var maxd = 0; var add = 0; for (var i = 0; i < n; ++i) { var ix = map[i][0]; var iy = map[i][1]; if (uf.GetSize(i) > 1) { foreach (var pos in Search(ix, iy, h, w, d)) { var pk = Key(pos.x, pos.y); visited.Add(pk); if (!dic.ContainsKey(pk)) { var set = new HashSet(); foreach (var p2 in Search(pos.x, pos.y, h, w, d)) { var k2 = Key(p2.x, p2.y); if (dic.ContainsKey(k2) && uf.GetSize(dic[k2]) > 1) { set.Add(uf.GetRoot(dic[k2])); } } maxd = Math.Max(maxd, set.Count - 1); } } } else if (add == 0) { foreach (var pos in Search(ix, iy, h, w, 1)) { var pk = Key(pos.x, pos.y); var flg = true; foreach (var p2 in Search(pos.x, pos.y, h, w, d)) { var k2 = Key(p2.x, p2.y); if (dic.ContainsKey(k2) && uf.GetSize(dic[k2]) > 1) { flg = false; break; } } if (flg) add = 1; break; } } } var ans = 0; for (var i = 0; i < n; ++i) if (uf.GetRoot(i) == i && uf.GetSize(i) > 1) ++ans; WriteLine($"{ans - maxd} {ans + add}"); } static IEnumerable<(int x, int y)> Search(int sx, int sy, int h, int w, int d) { for (var i = Math.Max(1, sx - d); i <= Math.Min(h, sx + d); ++i) { var di = Math.Abs(sx - i); for (var j = Math.Max(1, sy - d + di); j <= Math.Min(w, sy + d - di); ++j) { if (i != sx || j != sy) yield return (i, j); } } } static long Key(int x, int y) { return x * 1_000_000L + y; } class UnionFindTree { int[] roots; public UnionFindTree(int size) { roots = new int[size]; for (var i = 0; i < size; ++i) roots[i] = -1; } public int GetRoot(int a) { if (roots[a] < 0) return a; return roots[a] = GetRoot(roots[a]); } public bool IsSameTree(int a, int b) { return GetRoot(a) == GetRoot(b); } public bool Unite(int a, int b) { var x = GetRoot(a); var y = GetRoot(b); if (x == y) return false; if (-roots[x] < -roots[y]) { var tmp = x; x = y; y = tmp; } roots[x] += roots[y]; roots[y] = x; return true; } public int GetSize(int a) { return -roots[GetRoot(a)]; } } }