Given an array $a$ of length $n$, you can do at most $k$ operations of the following type on it:

choose $2$ different elements in the array, add $1$ to the first, and subtract $1$ from the second. However, all the elements of $a$ have to remain non-negative after this operation.

What is lexicographically the smallest array you can obtain?

An array $x$ is lexicographically smaller than an array $y$ if there exists an index $i$ such that $x_i<y_i$, and $x_j=y_j$ for all $1 \le j < i$. Less formally, at the first index $i$ in which they differ, $x_i<y_i$.


-----Input-----

The first line contains an integer $t$ ($1 \le t \le 20$) – the number of test cases you need to solve.

The first line of each test case contains $2$ integers $n$ and $k$ ($2 \le n \le 100$, $1 \le k \le 10000$) — the number of elements in the array and the maximum number of operations you can make.

The second line contains $n$ space-separated integers $a_1$, $a_2$, $\ldots$, $a_{n}$ ($0 \le a_i \le 100$) — the elements of the array $a$.


-----Output-----

For each test case, print the lexicographically smallest array you can obtain after at most $k$ operations.


-----Examples-----

Input
2
3 1
3 1 4
2 10
1 0
Output
2 1 5 
0 1


-----Note-----

In the second test case, we start by subtracting $1$ from the first element and adding $1$ to the second. Then, we can't get any lexicographically smaller arrays, because we can't make any of the elements negative.

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms


Solutions:
R = lambda : map(int, input().split())
(t,) = R()
exec(t * 'n,k=R();a=[*R()];i=0\nwhile k and i<n:d=min(a[i],k);a[i]-=d;a[-1]+=d;k-=d;i+=1\nprint(*a)\n')


import math
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	sm = 0
	for i in range(n - 1):
		if a[i] >= k:
			a[i] = a[i] - k
			a[-1] = a[-1] + k
			break
		else:
			k = k - a[i]
			a[-1] = a[-1] + a[i]
			a[i] = 0
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n - 1):
		d = min(k, a[i])
		a[i] -= d
		k -= d
		a[-1] += d
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(n - 1):
		if k == 0:
			break
		val = min(l[i], k)
		l[i] -= val
		l[n - 1] += val
		k -= val
	print(*l)


for _ in range(int(input())):
	(n, kit) = map(int, input().split())
	a = list(map(int, input().split()))
	s = 0
	for i in range(n):
		if kit > 0:
			t = min(a[i], kit)
			a[i] -= t
			kit -= t
			s += t
	a[-1] += s
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	s = l.copy()
	c = 0
	for i in range(n - 1):
		if s[i] >= k:
			s[i] = s[i] - k
			c += k
			k = 0
			break
		else:
			c += s[i]
			k = k - s[i]
			s[i] = 0
	s[-1] += c
	print(*s)


import sys
input = sys.stdin.readline

def solve():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	for i in range(n - 1):
		if arr[i] <= k:
			arr[-1] += arr[i]
			k -= arr[i]
			arr[i] = 0
		else:
			arr[-1] += k
			arr[i] -= k
			break
	return arr
for _ in range(int(input())):
	print(*solve())


for _ in range(0, int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	for i in range(0, n - 1):
		if ar[i] < k:
			k -= ar[i]
			ar[n - 1] += ar[i]
			ar[i] = 0
		else:
			ar[i] -= k
			ar[n - 1] += k
			k = 0
	print(' '.join((str(x) for x in ar)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	while k and i <= n - 2:
		x = min(a[i], k)
		a[i] -= x
		a[-1] += x
		i += 1
		k -= x
	print(*a)


for i in range(int(input())):
	arr1 = [int(_) for _ in input().split()]
	arr2 = [int(_) for _ in input().split()]
	x = arr1[1]
	for j in range(arr1[0]):
		if x > arr2[j]:
			x -= arr2[j]
			arr2[j] -= arr2[j]
		else:
			arr2[j] -= x
			x = 0
	if x == 0:
		arr2[-1] += arr1[1]
	else:
		arr2[-1] = arr1[1] - x
	print(*arr2)


def rearrange(arr):
	for (n, k, *ara) in arr:
		for i in range(n - 1):
			if k == 0:
				break
			mn = min(ara[i], k)
			ara[i] -= mn
			k -= mn
			ara[n - 1] += mn
		print(*ara)
t = int(input())
arr = []
for i in range(t):
	(n, k) = map(int, input().split())
	ara = list(map(int, input().split()))
	arr.append([n, k] + ara)
rearrange(arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	while k > 0 and i < n - 1:
		if a[i] != 0 and k >= a[i]:
			a[-1] = a[-1] + a[i]
			k = k - a[i]
			a[i] = 0
		elif a[i] != 0 and k <= a[i]:
			a[i] = a[i] - k
			a[-1] = a[-1] + k
			k = 0
		else:
			i = i + 1
	print(' '.join(map(str, a)))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	temp_k = k
	for i in range(n):
		min_value = min(a[i], temp_k)
		a[i] = a[i] - min_value
		temp_k = temp_k - min_value
	a[len(a) - 1] += k - temp_k
	print(*a)


import sys
txt = sys.stdin.read()
(a, *b) = txt.strip().split('\n')
for i in range(0, 2 * int(a), 2):
	(n, k, arr) = (*b[i].split(' '), b[i + 1].split(' '))
	k = int(k)
	arr = list(map(int, arr))
	arr[-1] += k
	for i in range(int(n) - 1):
		(arr[i], k) = (max([0, arr[i] - k]), max([0, k - arr[i]]))
		if not k:
			break
	arr[-1] -= k
	for i in arr:
		print(i, end=' ')
	print()


import sys
lines = sys.stdin.readlines()

def getline(line):
	return [int(x) for x in line.strip().split()]
m = getline(lines[0])[0]

def solve(n, k, arr):
	start = 0
	while k > 0 and start < len(arr) - 1:
		if arr[start] == 0:
			start += 1
			continue
		if arr[start] <= k:
			k -= arr[start]
			arr[-1] += arr[start]
			arr[start] = 0
		else:
			arr[start] -= k
			arr[-1] += k
			k = 0
	return arr
for i in range(1, len(lines), 2):
	(n, k) = getline(lines[i])
	arr = getline(lines[i + 1])
	for x in solve(n, k, arr):
		print(x, end=' ')
	print('\n')


def solve(arr, k):
	i = 0
	n = len(arr)
	while k > 0 and i < n - 1:
		op = min(k, arr[i])
		arr[i] -= op
		k -= op
		arr[-1] += op
		i += 1
	for a in arr:
		print(a, end=' ')
	print()
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	solve(arr, k)


import sys

def rl():
	return sys.stdin.readline().strip()

def rl_types(types):
	str_list = [x for x in sys.stdin.readline().strip().split(' ')]
	return [types[i](str_list[i]) for i in range(len(str_list))]

def pr(something):
	sys.stdout.write(str(something) + '\n')

def pra(array):
	sys.stdout.write(' '.join([str(x) for x in array]) + '\n')

def solve(array, k):
	total = 0
	n = len(array)
	for i in range(n - 1):
		a = array[i]
		maxsub = min(a, k)
		array[i] -= maxsub
		k -= maxsub
		array[-1] += maxsub
		if k == 0:
			break
	return array
NT = int(rl())
for ti in range(NT):
	(_, k) = [int(x) for x in rl().split(' ')]
	array = [int(x) for x in rl().split(' ')]
	res = solve(array, k)
	pra(res)


rr = lambda : input().strip()
rrm = lambda : map(int, rr().split())

def solve():
	(n, k) = rrm()
	a = list(rrm())
	a[-1] += k
	i = 0
	while k > 0:
		diff = min(a[i], k)
		k -= diff
		a[i] -= diff
		i += 1
	return a
T = int(rr())
for _ in range(T):
	ans = solve()
	print(*ans)


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	count = 0
	i = 0
	while i < n - 1 and count != k:
		if a[i] >= k:
			a[i] -= k
			a[n - 1] += k
			count += k
			k = 0
		else:
			a[n - 1] += a[i]
			k -= a[i]
			a[i] = 0
			count += a[i]
		i += 1
	print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	j = 0
	sum = 0
	x = 0
	while sum != k and j < n - 1:
		if sum + l[j] <= k:
			sum += l[j]
			l[j] = 0
		else:
			x = k - sum
			sum = k
			l[j] -= x
		j += 1
	l[n - 1] += sum
	print(*l)


T = int(input())
while T:
	T -= 1
	(n, k) = map(int, input().split())
	nums = list(map(int, input().split()))
	for i in range(n - 1):
		if k <= 0:
			break
		if nums[i] >= k:
			nums[i] -= k
			nums[-1] += k
			k = 0
		if nums[i] < k:
			k -= nums[i]
			nums[-1] += nums[i]
			nums[i] = 0
	for i in nums:
		print(i, end=' ')
	print()


t = int(input())
for w in range(t):
	inp = input().split()
	n = int(inp[0])
	k = int(inp[1])
	arr = []
	inp = input().split()
	for i in inp:
		arr.append(int(i))
	for j in range(n - 1):
		if arr[j] <= k:
			arr[-1] += arr[j]
			k -= arr[j]
			arr[j] = 0
		else:
			arr[j] -= k
			arr[-1] += k
			break
	for i in arr:
		print(i, end=' ')
	print()


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	(n, k) = R()
	a = [*R()]
	i = 0
	while k and i < n:
		d = min(a[i], k)
		a[i] -= d
		a[-1] += d
		k -= d
		i += 1
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	for i in range(n):
		temp = lst[i] - k
		if temp > 0:
			lst[i] -= k
			lst[-1] += k
			k = 0
			break
		elif i != n - 1:
			lst[-1] += lst[i]
			k -= lst[i]
			lst[i] = 0
	print(*lst)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	i = 0
	while i < len(ls) and k > 0:
		z = min(ls[i], k)
		k -= z
		ls[i] -= z
		ls[-1] += z
		i += 1
	print(*ls)


def funn(a, k):
	sm = 0
	n = len(a)
	for i in range(n - 1):
		if a[i] > 0:
			if a[i] <= k:
				sm += a[i]
				k -= a[i]
				a[i] = 0
			else:
				sm += k
				a[i] -= k
				k = 0
	a[-1] += sm
	return a
t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	w = funn(a, k)
	for i in w:
		print(i, end=' ')
	print()
	t = t - 1


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	for i in range(len(l) - 1):
		if l[i] < k:
			k -= l[i]
			l[n - 1] += l[i]
			l[i] = 0
		else:
			l[i] -= k
			l[n - 1] += k
			break
	print(' '.join(map(str, l)))


def tit_tat(arr, n, k):
	for i in range(n - 1):
		if arr[i] == 0:
			continue
		if k - arr[i] >= 0:
			k -= arr[i]
			arr[n - 1] += arr[i]
			arr[i] = 0
		else:
			arr[i] -= k
			arr[n - 1] += k
			k = 0
			break
	return arr
t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	print(' '.join([str(num) for num in tit_tat(A, n, k)]))
	t -= 1


for test_case in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ik = k
	ans = []
	for i in range(n - 1):
		if a[i] > 0:
			if a[i] >= k:
				t = a[i] - k
				ans.append(t)
				k = 0
			else:
				ans.append(0)
				k = k - a[i]
		else:
			ans.append(0)
	ans.append(a[n - 1] + ik - k)
	print(*ans)


t = int(input())
while t:
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	i = 0
	j = n - 1
	if a[i] >= k:
		a[i] -= k
		a[j] += k
	else:
		s = 0
		while i < n:
			if s + a[i] <= k and i < n:
				s += a[i]
				a[i] = 0
			else:
				break
			i += 1
		if i < n and k - s > 0 and (a[i] >= k - s):
			a[i] = a[i] - (k - s)
			s = s + k - s
		a[n - 1] += s
	print(*a)
	t -= 1


t_case = int(input())
for i in range(t_case):
	inp_lst = input().split()
	(n, k) = (int(inp_lst[0]), int(inp_lst[1]))
	lst = [int(i) for i in input().split()]
	ind = 0
	while ind + 1 < n and k > 0:
		if lst[ind] < k:
			k -= lst[ind]
			lst[-1] += lst[ind]
			lst[ind] = 0
			ind += 1
		else:
			lst[ind] -= k
			lst[-1] += k
			break
	print(' '.join((str(i) for i in lst)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	j = n - 1
	while k > 0 and i < j:
		temp = l[i]
		if l[i] >= k:
			l[i] = l[i] - k
			l[j] += k
			break
		else:
			l[i] = 0
			l[j] += temp
			k = k - temp
		i += 1
	for i in l:
		print(i, end=' ')
	print()


for testcase in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	i = 0
	while k > 0 and i < n - 1:
		subtract = min(a[i], k)
		k -= subtract
		a[i] -= subtract
		a[-1] += subtract
		i = i + 1
	for u in a:
		print(u, end=' ')
	print('')


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if k >= a[i]:
			k -= a[i]
			to_add = a[i]
			a[i] = 0
			a[-1] += to_add
		else:
			a[i] -= k
			a[-1] += k
			break
	print(' '.join(map(str, a)))


def minSequence(a, k):
	if len(a) == 2:
		if a[0] > k:
			a[0] = a[0] - k
			a[1] = a[1] + k
		else:
			a[1] = sum(a)
			a[0] = 0
	else:
		i = 0
		while a[i] <= k and i != len(a) - 1:
			a[-1] += a[i]
			k -= a[i]
			a[i] = 0
			i += 1
		if i != len(a) - 1:
			if k != 0:
				a[i] -= k
				a[-1] += k
	return a
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a = minSequence(a, k)
	for i in a:
		print(i, end=' ')
	print(end='\n')


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	l = 0
	r = n - 1
	while l < n - 1 and k > 0:
		c = min(a[l], k)
		k -= c
		a[l] -= c
		a[r] += c
		l += 1
	print(*a)


t = int(input())
for _ in range(t):
	(a, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ptr1 = 0
	ptr2 = len(arr) - 1
	while k > 0 and ptr1 != ptr2:
		if arr[ptr1] == 0:
			ptr1 += 1
			continue
		else:
			arr[ptr1] -= 1
			arr[ptr2] += 1
			k -= 1
	print(*arr)


t = int(input())
while t > 0:
	(a, x) = map(int, input().split())
	b = list(map(int, input().split()))
	for i in range(a - 1):
		if x > 0:
			if b[i] > 0:
				if b[i] >= x:
					b[i] -= x
					b[a - 1] += x
					x = 0
				else:
					b[a - 1] += b[i]
					x -= b[i]
					b[i] = 0
			else:
				pass
		else:
			break
	print(*b)
	t -= 1


from sys import stdin
input = stdin.readline
from collections import Counter
from itertools import accumulate

def solve():
	(n, k) = [int(char) for char in input().split()]
	A = [int(char) for char in input().split()]
	for i in range(n - 1):
		if k == 0:
			break
		diff = min(k, A[i])
		k -= diff
		A[i] -= diff
		A[-1] += diff
	return A
for _ in range(int(input())):
	print(*solve())


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	i = 0
	while k > 0 and i < n - 1:
		diff = arr[i] - k
		if diff >= 0:
			arr[i] -= k
			arr[n - 1] += k
			k -= k
		else:
			k -= arr[i]
			arr[n - 1] += arr[i]
			arr[i] = 0
			i += 1
	for x in arr:
		print(x, end=' ')
	print()


import sys
inputs = []
for line in sys.stdin:
	inputs.append(line.rstrip())
times = int(inputs[0])
values = []
n_k = []
starting = 1
for i in range(0, times):
	temp = [int(x) for x in inputs[starting].split(' ')]
	n_k.append(temp)
	temp = [int(x) for x in inputs[starting + 1].split(' ')]
	values.append(temp)
	starting += 2
for itera in range(times):
	prev = []
	i = n_k[itera][1]
	right = n_k[itera][0] - 1
	left = 0
	while i != 0:
		if left >= right:
			break
		prev = values[itera]
		shift = 0
		if values[itera][left] > i:
			shift = i
		else:
			shift = values[itera][left]
		i -= shift
		values[itera][left] -= shift
		values[itera][right] += shift
		if values[itera][left] == 0:
			left += 1
for i in values:
	for j in i:
		print(j, end=' ')
	print()


N = int(input())
for i in range(N):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	s = 0
	for j in range(n - 1):
		if a[j] == 0:
			continue
		if k <= 0:
			break
		while a[j] != 0 and k > 0:
			k -= 1
			s += 1
			a[j] -= 1
	a[n - 1] += s
	print(' '.join(map(str, a)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	spic = list(map(int, input().split()))
	yk = 0
	while yk != n - 1 and k:
		if spic[yk] == 0:
			yk += 1
			continue
		spic[yk] -= 1
		spic[-1] += 1
		k -= 1
	print(*spic)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n - 1):
		m = min(k, a[i])
		a[i] -= m
		a[n - 1] += m
		k -= m
	print(' '.join(map(str, a)))


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	v = [int(i) for i in input().split()]
	for i in range(n - 1):
		if v[i] < k:
			v[-1] += v[i]
			k -= v[i]
			v[i] = 0
		else:
			v[-1] += k
			v[i] -= k
			k = 0
	print(*v)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	for j in range(n - 1):
		if a[j] >= k:
			a[j] = a[j] - k
			c = c + k
			k = 0
			break
		else:
			c = c + a[j]
			k = k - a[j]
			a[j] = 0
	a[-1] = a[-1] + c
	for j in a:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	while True:
		if l[i] > 0 and i != a - 1:
			c = l[i]
			if b >= c:
				l[-1] += c
				l[i] -= c
				b -= c
			else:
				l[-1] += b
				l[i] -= b
				break
		elif i == a - 1:
			break
		i += 1
	print(*l)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n):
		sub = min(a[i], k)
		a[i] = a[i] - sub
		a[-1] = a[-1] + sub
		k = k - sub
	print(*a, sep=' ')


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if k:
			d = min(k, a[i])
			a[i] -= d
			k -= d
			a[-1] += d
		else:
			break
	print(*a)


num = int(input())
for i in range(num):
	info = input()
	info = info.split(' ')
	arr = input()
	arr = arr.split(' ')
	n = int(info[0])
	k = int(info[1])
	moreThanOne = [x for x in arr if int(x) > 0]
	if len(moreThanOne):
		firstMore = arr.index(moreThanOne[0])
		if firstMore != n - 1:
			for j in range(firstMore, n - 1):
				if k > 0:
					if k > int(arr[j]):
						temp = int(arr[j])
						arr[j] = '0'
						arr[n - 1] = f'{int(arr[n - 1]) + temp}'
						k -= temp
					else:
						arr[j] = f'{int(arr[j]) - k}'
						arr[n - 1] = f'{int(arr[n - 1]) + k}'
						break
				else:
					break
	print(' '.join(arr))


import math
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in range(n - 1):
		if not k:
			break
		if A[i] >= k:
			A[i] = A[i] - k
			A[-1] += k
			k = 0
		else:
			A[-1] += A[i]
			k -= A[i]
			A[i] = 0
	print(' '.join(map(str, A)))


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	for i in range(0, n - 1):
		while arr[i] > 0 and k > 0:
			arr[i] -= 1
			arr[n - 1] += 1
			k -= 1
	print(*arr)


for _ in range(int(input())):
	(n, k) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	x = n - 1
	for i in range(n):
		if x == i or k == 0:
			break
		if a[i] > 0:
			if k >= a[i]:
				k -= a[i]
				a[x] += a[i]
				a[i] = 0
			else:
				a[i] -= k
				a[x] += k
				k = 0
	for n in a:
		print(n, end=' ')
	print()


t = int(input())
for case in range(t):
	(n, k) = list(map(int, input().split(' ')))
	numbers = list(map(int, input().split(' ')))
	for i in range(len(numbers)):
		if k >= numbers[i]:
			k -= numbers[i]
			temp = numbers[i]
			numbers[i] = 0
			numbers[-1] += temp
		else:
			numbers[i] -= k
			numbers[-1] += k
			break
	print(' '.join([str(i) for i in numbers]))


def main():
	num_cases = int(input())
	for case_num in range(1, num_cases + 1):
		solve(case_num)

def solve(case_num):
	(n, k) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	for (i, a) in enumerate(A):
		if a <= k:
			A[i] = 0
			A[-1] += a
			k -= a
		else:
			A[i] -= k
			A[-1] += k
			k = 0
			break
	print(' '.join((str(a) for a in A)))
main()


def helper(a, k):
	i = 0
	while i < len(a) - 1 and k > 0:
		curr = min(k, a[i])
		a[i] -= curr
		a[-1] += curr
		k -= curr
		i += 1
	return a
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	res = helper(a, k)
	print(' '.join(map(str, res)))


t = int(input())
for _ in range(t):
	(n, k) = (int(num) for num in input().split())
	a_lst = list((int(a) for a in input().split()))
	i = 0
	while k and i < n - 1:
		can_be_subtracted = min(a_lst[i], k)
		k -= can_be_subtracted
		a_lst[i] -= can_be_subtracted
		a_lst[-1] += can_be_subtracted
		i += 1
	print(*a_lst)


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		aage = 0
		piche = n - 1
		while k > 0 and aage < piche:
			if a[aage] > 0:
				if a[aage] > k:
					a[aage] -= k
					a[piche] += k
					k = 0
				else:
					k -= a[aage]
					a[piche] += a[aage]
					a[aage] = 0
				aage += 1
			else:
				aage += 1
		print(*a)
main()


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		for i in range(n - 1):
			p = min(k, a[i])
			a[-1] += p
			a[i] -= p
			k -= p
		print(*a)
main()


t = int(input())

def smallest(L, n, k):
	counter = k
	i = 0
	while i < n - 1 and counter > 0:
		if L[i] > 0:
			if L[i] > counter:
				L[i] -= counter
				L[-1] += counter
				counter = 0
			else:
				L[-1] += L[i]
				counter -= L[i]
				L[i] = 0
		i += 1
	return L
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	L = [int(x) for x in input().split()]
	E = smallest(L, n, k)
	for element in E:
		print(element, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	while k != 0:
		if l[i] <= k:
			a = l[i]
			l[i] = 0
			k = k - a
			l[-1] = l[-1] + a
		else:
			l[i] = l[i] - k
			l[-1] = l[-1] + k
			k = 0
		i = i + 1
		if i == n - 1:
			break
	for i in l:
		print(i, end=' ')
	print()


t = int(input())
for t in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	while i < n - 1 and k > 0:
		if l[i] > 0:
			if l[i] >= k:
				l[i] = l[i] - k
				l[-1] = l[-1] + k
				k = 0
				break
			else:
				p = l[i]
				k = k - l[i]
				l[i] = 0
				l[-1] = l[-1] + p
				i = i + 1
		else:
			i = i + 1
	print(*l)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = [int(j) for j in input().split()]
	for j in range(n - 1):
		c = min(a[j], k)
		a[j] -= c
		a[-1] += c
		k -= c
		if k == 0:
			break
	print(*a)


aaaaa = int(input())
for i in range(aaaaa):
	b = input().split()
	c = input().split()
	num = int(b[1])
	for (po, j) in enumerate(c):
		c[po] = int(j)
	po = 0
	l = len(c)
	while True:
		if c[po] >= num:
			c[po] -= num
			c[l - 1] += num
			break
		else:
			c[l - 1] += c[po]
			num -= c[po]
			c[po] = 0
			po += 1
		if po >= l - 1:
			break
	for j in c:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	a_index = 0
	while k >= 0:
		if a_index == n - 1:
			break
		if k > arr[a_index]:
			k = k - arr[a_index]
			arr[-1] += arr[a_index]
			arr[a_index] = 0
			a_index += 1
		else:
			arr[-1] += k
			arr[a_index] -= k
			break
	print(' '.join([str(x) for x in arr]))


import sys
import os.path
if os.path.exists('input_file.txt'):
	sys.stdin = open('input_file.txt', 'r')
	sys.stdout = open('output_file.txt', 'w')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if k == 0:
			break
		elif a[i] > 0:
			if a[i] >= k:
				a[i] -= k
				a[-1] += k
				k = 0
			else:
				ss = k - a[i]
				a[-1] += a[i]
				k -= a[i]
				a[i] = 0
	for ii in a:
		print(ii, end=' ')
	print()


t = int(input())
for i in range(0, t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	mm = 0
	for ii in a:
		if ii == 0:
			mm = mm + 1
	if mm == len(a) or (mm == len(a) - 1 and a[len(a) - 1] > 0):
		print(*a)
	else:
		for i in range(0, len(a) - 1):
			if a[i] > 0:
				mini = min(a[i], m)
				a[i] = a[i] - m
				if a[i] < 0:
					a[i] = 0
				a[i + 1] = a[i + 1] + mini
		print(*a)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	for i in range(n - 1):
		if k - arr[i] >= 0:
			arr[n - 1] += arr[i]
			k = k - arr[i]
			arr[i] = 0
		else:
			arr[n - 1] += k
			arr[i] -= k
			k = 0
	for i in arr:
		print(i, end=' ')
	print()


list1 = []
for i in range(int(input())):
	(n, k) = map(lambda x: int(x), input().split())
	s = input().split()
	j = 0
	while k > 0 and s[:-1] != ['0'] * (n - 1):
		x = int(s[j])
		s[-1] = str(int(s[-1]) + min(k, x))
		s[j] = str(max(0, x - k))
		k = max(k - x, 0)
		j += 1
	list1.append(' '.join(s))
print(*list1, sep='\n')


def fun(ls, ks):
	(n, k) = ks
	temp = k
	if n == 2:
		if k >= ls[0]:
			prv = ls[0]
			ls[0] = 0
			ls[1] = ls[1] + prv
		else:
			ls[0] = ls[0] - k
			ls[1] = ls[1] + k
		print(*ls)
		return
	sm = sum(ls[:-1])
	if k < sm:
		for (i, val) in enumerate(ls):
			if val <= k:
				ls[i] = 0
				k = k - val
			else:
				ls[i] = val - k
				break
		ls[-1] = ls[-1] + temp
		print(*ls)
	else:
		print(*[0] * (n - 1) + [ls[-1] + sm])
T = int(input())
for i in range(T):
	ks = list(map(int, input().split()))
	ls = list(map(int, input().split()))
	fun(ls, ks)


import math
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	for _ in range(n - 1):
		if k == 0:
			break
		elif k < a[_]:
			a[-1] += k
			a[_] -= k
			k = 0
		elif k >= a[_]:
			a[-1] += a[_]
			k -= a[_]
			a[_] = 0
	print(*a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n - 1):
		if a[i] >= k:
			a[i] -= k
			a[-1] += k
			break
		else:
			k -= a[i]
			a[-1] += a[i]
			a[i] = 0
	print(*a)


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	d = []
	s = 0
	z = 0
	for j in range(n - 1):
		s = s + a[j]
		if s >= k:
			i = j
			z = 1
			break
	if z == 1:
		d = a[i:]
		d[0] = d[0] - (k - (s - a[i]))
		d[len(d) - 1] = d[len(d) - 1] + k
		a = [0] * i + d
	else:
		v = a[n - 1]
		a = [0] * (n - 1)
		a.append(v + s)
	print(*a, sep=' ')


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	if k <= arr[0]:
		sub = min(arr[0], k)
		arr[0] = arr[0] - sub
		arr[n - 1] = arr[n - 1] + sub
		for i in arr:
			print(i, end=' ')
		print()
	else:
		for i in range(0, n - 1):
			temp = k
			k = k - arr[i]
			arr[n - 1] += min(arr[i], temp)
			arr[i] = max(arr[i] - temp, 0)
			if k <= 0:
				break
		for i in arr:
			print(i, end=' ')
		print()


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	As = list(map(int, input().split(' ')))
	i = 0
	while k and i < n - 1:
		if k >= As[i]:
			k -= As[i]
			As[n - 1] += As[i]
			As[i] = 0
			i += 1
		else:
			As[i] -= k
			As[n - 1] += k
			k = 0
	print(*As)


import math

def solve():
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	tmp = k
	i = 0
	while i < n and tmp > 0:
		if l[i] == 0:
			i += 1
			continue
		if tmp >= l[i]:
			tmp -= l[i]
			l[i] = 0
			i += 1
		else:
			l[i] -= tmp
			tmp = 0
			i += 1
	l[n - 1] += k - tmp
	print(*l)
t = int(input())
while t > 0:
	t -= 1
	solve()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	for i in range(n - 1):
		if k == 0:
			break
		if l[i] == 0:
			continue
		if k <= l[i]:
			l[i] -= k
			l[n - 1] += k
			k = 0
		else:
			k -= l[i]
			l[n - 1] += l[i]
			l[i] = 0
	for i in range(n):
		l[i] = str(l[i])
	print(' '.join(l))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	count = k
	i = 0
	m = 0
	while count > 0 and i < n:
		if count >= l[i]:
			count -= l[i]
			m += l[i]
			l[i] = 0
			i += 1
		else:
			l[i] -= count
			m += count
			count = 0
	l[n - 1] += m
	print(*l)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	ls = list(map(int, input().split()))
	pend = 0
	for i in range(n - 1):
		x = min(ls[i], k)
		ls[i] -= x
		pend += x
		k -= x
		if k == 0:
			break
	ls[-1] += pend
	print(*ls)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	m = n - 1
	for i in range(m):
		if arr[i] >= k:
			arr[i] = arr[i] - k
			arr[m] += k
			break
		else:
			k -= arr[i]
			arr[m] += arr[i]
			arr[i] = 0
	for i in range(n):
		print(arr[i], end=' ')
	print('')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if l.count(0) == n:
		print(*l)
		continue
	for i in range(n):
		if k == 0:
			break
		if k >= l[i]:
			k -= l[i]
			l[-1] += l[i]
			l[i] = 0
		else:
			l[i] -= k
			l[-1] += k
			k = 0
		c = 0
		if l[-1] != 0 and l.count(0) == n - 1:
			k = 0
	print(*l)