# sumSubsets and findSubsets solution is used from # https://www.geeksforgeeks.org/perfect-sum-problem/ with some modifications def sumSubsets(sets, n, target): # Create the new array with size # equal to array set[] to create # binary array as per n(decimal number) x = [0] * len(sets) j = len(sets) - 1 # Convert the array into binary array while (n > 0): x[j] = n % 2 n = n // 2 j -= 1 sum = 0 # Calculate the sum of this subset for i in range(len(sets)): if (x[i] == 1): sum += sets[i] # Check whether sum is equal to target # if it is equal, then print the subset if (sum == target): arr2 = [] for i in range(len(sets)): if (x[i] == 1): arr2.append(sets[i]) return arr2 # Function to find the subsets with sum K def findSubsets(arr, K): # Calculate the total no. of subsets x = pow(2, len(arr)) # Run loop till total no. of subsets # and call the function for each subset arr3 = [] for m in range(1, x): tmp = sumSubsets(arr, m, K) if tmp is not None: arr3.append(tmp) return arr3 # Driver code if __name__ == "__main__": N, K = map(int, input().split()) arr = list(map(int, input().split())) sums = [] for i in range(0, N): columns = [0 for l in range(N)] start = K + 1 - arr[i] end = K for k in range(start, end+1): sums = findSubsets(arr[:i] + arr[i+1:], k) for item in sums: columns[len(item)] += 1 columns[len(item)] %= 167772161 for m in range(1, len(columns)): if m != len(columns)-1: print(columns[m], end=" ") else: print(columns[m])