t = int(input())
for inputs in range(t):
	m,n = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	xarr = [int(x) for x in input().split(' ')]
	suma = sum(arr)
	ans = [((int(x/suma))*n) for x in xarr]
	xarr = [int(x%suma) for x in xarr]
	print(ans)
	print(xarr)
	for x,an in zip(xarr,ans):
		if x==0 and an>0:
			an = an-1
		if x != 0:
			for a in arr:
				x = x-a
				if x!=0:
					an = an + 1 
				else:
					break
		if x==0 and an>0:
			print(an, end =" ")
		else:
			print("-1", end =" ")
	print()