using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static long NN => long.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 p = NList; var (n, f) = (p[0], p[1]); var a = NList; var b = NList; var c = NList; var ans = new int[n]; var dp = new bool[n * f + 1]; dp[0] = true; var move = new HashSet[f + 1]; move[0] = new HashSet(); for (var i = 0; i < move.Length; ++i) move[i] = new HashSet{ 0 }; for (var i = 0; i < n; ++i) { var add = new HashSet(); foreach (var cur in move[a[i]]) if (!dp[cur + a[i]]) { dp[cur + a[i]] = true; add.Add(cur + a[i]); } move[a[i]] = new HashSet(); foreach (var cur in move[b[i]]) if (!dp[cur + b[i]]) { dp[cur + b[i]] = true; add.Add(cur + b[i]); } move[b[i]] = new HashSet(); foreach (var cur in move[c[i]]) if (!dp[cur + c[i]]) { dp[cur + c[i]] = true; add.Add(cur + c[i]); } foreach (var ai in add) for (var j = 1; j < move.Length; ++j) move[j].Add(ai); if (i == 0) ans[0] = add.Count + 1; else ans[i] = ans[i - 1] + add.Count; } WriteLine(string.Join("\n", ans)); } }