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 (n, m) = (c[0], c[1]); var map = NArr(n); var conv = new long[n][]; for (var i = 0; i < n; ++i) conv[i] = new long[] { (long)map[i][0] - map[i][1] - m + map[i][2], (long)map[i][0] + map[i][1] - m + map[i][2], (long)map[i][0] - map[i][1] + m - map[i][2], (long)map[i][0] + map[i][1] + m - map[i][2] }; var xset = new HashSet(); var yset = new HashSet(); for (var i = 0; i < n; ++i) { xset.Add(conv[i][0]); yset.Add(conv[i][1]); xset.Add(conv[i][2]); yset.Add(conv[i][3]); } var xlist = new List(xset); xlist.Sort(); var ylist = new List(yset); ylist.Sort(); var xdic = new Dictionary(); for (var i = 0; i < xlist.Count; ++i) xdic[xlist[i]] = i; var ydic = new Dictionary(); for (var i = 0; i < ylist.Count; ++i) ydic[ylist[i]] = i; var inlist = new List<(long id, int yc)>(); var outlist = new List<(long id, int yc)>(); for (var i = 0; i < n; ++i) { inlist.Add((i, ydic[conv[i][1]])); outlist.Add((i, ydic[conv[i][3]])); } inlist.Sort((l, r) => l.yc.CompareTo(r.yc)); outlist.Sort((l, r) => l.yc.CompareTo(r.yc)); var ipos = 0; var opos = 0; var mod = 998_244_353; var rev2 = 499_122_177; var ans = new long[n + 1]; var ft = new FenwickTree(xlist.Count + 1); for (var yc = 0; yc < ylist.Count; ++yc) { if (ipos < inlist.Count && inlist[ipos].yc == yc) { ft.Add(xdic[conv[inlist[ipos].id][0]], 1); ft.Add(xdic[conv[inlist[ipos].id][2]], -1); ++ipos; } if (opos < outlist.Count && outlist[opos].yc == yc) { ft.Add(xdic[conv[outlist[opos].id][0]], -1); ft.Add(xdic[conv[outlist[opos].id][2]], 1); ++opos; } if (yc + 1 == ylist.Count) continue; for (var xc = 0; xc + 1 < xlist.Count; ++xc) { var cnt = ft.Sum(xc); ans[cnt] = (ans[cnt] + (xlist[xc + 1] - xlist[xc]) % mod * ((ylist[yc + 1] - ylist[yc]) % mod)) % mod; } } WriteLine(string.Join("\n", ans.Skip(1).Select(ai => ai * rev2 % mod))); } class FenwickTree { int size; long[] tree; public FenwickTree(int size) { this.size = size; tree = new long[size + 2]; } public void Add(int index, int value) { ++index; for (var x = index; x <= size; x += (x & -x)) tree[x] += value; } /// 先頭からindexまでの和(include index) public long Sum(int index) { if (index < 0) return 0; ++index; var sum = 0L; for (var x = index; x > 0; x -= (x & -x)) sum += tree[x]; return sum; } /// Sum(x) >= value となる最小のxを求める // 各要素は非負であること public int LowerBound(long value) { if (value < 0) return -1; var x = 0; var b = 1; while (b * 2 <= size) b <<= 1; for (var k = b; k > 0; k >>= 1) { if (x + k <= size && tree[x + k] < value) { value -= tree[x + k]; x += k; } } return x; } } }