There are $N$ buckets numbered $1$ through $N$. The buckets contain balls; each ball has a color between $1$ and $K$. Let's denote the number of balls with color $j$ that are initially in bucket $i$ by $a_{i, j}$.
For each $i$ from $1$ to $N-1$ (in this order), someone draws a ball uniformly at random from bucket $i$ and puts it into bucket $i+1$, then continues to draw the next ball. After putting a ball in bucket $N$, this person draws a ball, again uniformly at random, from bucket $N$.
For each color from $1$ to $K$, find the probability that the ball drawn from bucket $N$ has this color.

-----Input-----
- The first line of the input contains two space-separated integers $N$ and $K$. 
- $N$ lines follow. For each $i$ ($1 \le i \le N$), the $i$-th of these lines contains $K$ space-separated integers $a_{i, 1}, a_{i, 2}, \ldots, a_{i, K}$.

-----Output-----
Print a single line containing $K$ space-separated real numbers. For each valid $i$, the $i$-th of these numbers should denote the probability that the last drawn ball has color $i$. your answer will be considered correct if absolute or relative error does not exceed $10^{-6}$

-----Constraints-----
- $1 \le N, K \le 1,000$
- $0 \le a_{i, j} \le 10$ for each valid $i, j$
- initially, there is at least one ball in bucket $1$

-----Subtasks-----
Subtask #1 (30 points): $1 \le N, K \le 100$
Subtask #2 (70 points): original constraints

-----Example Input-----
2 2
0 1
1 1

-----Example Output-----
0.333333 0.666667

-----Explanation-----

Difficulty: MEDIUM_HARD

Solutions:
a = input()
(n, k) = a.split()
n = int(n)
k = int(k)
A = []
sum = []
for i in range(n):
	A.append(list(map(int, input().split())))
for i in range(n):
	sum.append(0)
	for j in range(k):
		sum[i] = sum[i] + A[i][j]
for j in range(k):
	p1 = A[0][j] / sum[0]
	for i in range(1, n):
		p1 = (A[i][j] + 1) * p1 / (sum[i] + 1) + A[i][j] * (1 - p1) / (sum[i] + 1)
	print('%.6f' % p1, end=' ')


(N, K) = map(int, input().split(' '))
ball = []
for i in range(N):
	ball.append(list(map(int, input().split(' '))))
prob = [[0 for i in range(K)] for j in range(N)]
for i in range(N):
	temp = 0
	for j in range(K):
		temp += ball[i][j]
	ball[i].append(temp)
for i in range(K):
	prob[0][i] = ball[0][i] / ball[0][K]
for i in range(1, N):
	c = ball[i][K]
	for j in range(0, K):
		b = ball[i][j]
		prob[i][j] = (b + prob[i - 1][j]) / (c + 1)
for i in range(K):
	print('%.6f' % prob[N - 1][i], end=' ')


(n, k) = map(int, input().split())
bucket = list(map(int, input().split()))
pb = sum(bucket)
prop = [i / pb if pb > 0 else 0 for i in bucket]
for i in range(1, n):
	bucket = list(map(int, input().split()))
	nb = sum(bucket) + 1
	current = [0 for _ in range(k)]
	for j in range(k):
		current[j] = (bucket[j] + 1) / nb * prop[j] + bucket[j] / nb * (1 - prop[j])
	prop = current[:]
print(('{:.6f} ' * n).format(*prop))


(n, k) = map(int, input().split())
arr = []
for i in range(n):
	kl = list(map(int, input().split()))
	arr.append(kl)
pre = []
for i in range(1005):
	pre.append([])
for i in range(1005):
	for j in range(1005):
		pre[i].append(0)
s = [0] * 1005
for i in range(0, k):
	pre[0][i] = arr[0][i]
	s[0] += pre[0][i]
for i in range(1, n):
	for j in range(k):
		pre[i][j] = arr[i][j] + pre[i - 1][j] / s[i - 1]
		s[i] += pre[i][j]
for i in range(k):
	print('%0.6f' % (pre[n - 1][i] / s[n - 1]), end=' ')
print()


(n, k) = map(int, input().split())
prob = [0 for i in range(k)]
for i in range(n):
	vals = list(map(int, input().split()))
	sumval = sum(vals)
	if i == 0:
		for j in range(k):
			prob[j] = vals[j] / sumval
	else:
		for j in range(k):
			prob[j] = (vals[j] + prob[j]) / (sumval + 1)
for i in range(0, len(prob) - 1):
	print(round(prob[i], 6), end=' ')
print(round(prob[-1], 6), end='')


(n, k) = map(int, input().split())
game = []
for i in range(n):
	game.append(list(map(int, input().split())))
summ = 0
for i in range(n - 1):
	for j in range(k):
		summ += game[i][j]
	for j in range(k):
		game[i + 1][j] += game[i][j] / summ
	summ = 0
deno = sum(game[i + 1])
for i in game[i + 1]:
	print(str.format('{0:.6f}', i / deno), end=' ')


(n, k) = map(int, input().split())
prob = [0 for i in range(k)]
for i in range(n):
	vals = list(map(int, input().split()))
	s = sum(vals)
	if i == 0:
		for j in range(k):
			prob[j] = vals[j] / s
	else:
		for j in range(k):
			prob[j] = (vals[j] + prob[j]) / (s + 1)
prob = [round(prob[i], 6) for i in range(k)]
print(*prob)


from collections import defaultdict
(n, k) = map(int, input().split())
record = {}
record = defaultdict(lambda : 1, record)
for i in range(n):
	inlist = list(map(int, input().split()))
	total = sum(inlist)
	for j in range(k):
		if i != 0:
			record[str(j)] = record[str(j)] * (inlist[j] + 1) / (total + 1) + (1 - record[str(j)]) * inlist[j] / (total + 1)
		elif i == 0:
			record[str(j)] *= inlist[j] / total
for i in range(k):
	print(round(record[str(i)], 6), end=' ')


(n, k) = list(map(int, input().split()))
prob_if_adding = [0 for _ in range(k)]
for i in range(n):
	bucket = list(map(int, input().split()))
	s = sum(bucket)
	if i == 0:
		for j in range(k):
			prob_if_adding[j] = bucket[j] / s
	else:
		for j in range(k):
			prob_if_adding[j] = prob_if_adding[j] * ((bucket[j] + 1) / (s + 1)) + (1 - prob_if_adding[j]) * (bucket[j] / (s + 1))
for j in range(k):
	print(round(prob_if_adding[j], 6), end=' ')


def main():
	(n, k) = tuple(map(int, input().split()))
	a = [list(map(int, input().split())) for _ in range(n)]
	p = [a[0][i] / sum(a[0]) for i in range(k)]
	for i in range(1, n):
		s = sum(a[i]) + 1
		p = [(p[j] * (a[i][j] + 1) + (1 - p[j]) * a[i][j]) / s for j in range(k)]
	for i in range(k):
		print(round(p[i], 6), end=' ')
main()


(n, k) = map(int, input().split())
a = [[] for i in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
ans = [[0 for i in range(k)] for j in range(n)]
sumi = []
for i in range(n):
	p = 0
	for j in range(k):
		p += a[i][j]
	sumi.append(p)
for j in range(k):
	for i in range(n):
		if i == 0:
			ans[i][j] = a[i][j] / sumi[0]
		else:
			ans[i][j] = ans[i - 1][j] * (a[i][j] + 1) / (sumi[i] + 1) + (1 - ans[i - 1][j]) * a[i][j] / (sumi[i] + 1)
	x = ans[n - 1][j] * pow(10, 6)
	if x % 10 >= 5:
		x = int(x)
		x += 1
	else:
		x = int(x)
	print(x / 1000000, end=' ')


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
x = []
s = sum(l[0])
for i in l[0]:
	x.append(i / s)
s = []
for i in l:
	s.append(sum(i))
for i in range(1, n):
	y = []
	for j in range(k):
		a = 0
		a = l[i][j] / (s[i] + 1) * (sum(x) - x[j])
		a += x[j] * ((l[i][j] + 1) / (s[i] + 1))
		y.append(a)
	x = y[:]
for i in x:
	print(round(i, 6), end=' ')


(n, k) = map(int, input().split())
sum = [0] * n
l = [[0 for i in range(k)] for j in range(n)]
for i in range(n):
	l[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(k):
		sum[i] += l[i][j]
for i in range(k):
	x = l[0][i]
	carry = x / sum[0]
	for j in range(1, n):
		y = l[j][i]
		z = sum[j]
		carry = carry * ((y + 1) / (z + 1)) + (1 - carry) * (y / (z + 1))
	print(round(carry, 6), end=' ')


import numpy as np
(n, k) = map(int, input().split())
matrix = []
for i in range(n):
	matrix.append(list(map(int, input().split())))
bucket = np.zeros([k], dtype=float)
deno = sum(matrix[0])
for j in range(k):
	bucket[j] += matrix[0][j] / deno
for i in range(1, n):
	deno = sum(matrix[i]) + 1
	for j in range(k):
		bucket[j] = (bucket[j] * (matrix[i][j] + 1) + (1 - bucket[j]) * matrix[i][j]) / deno
print(' '.join((str(round(x, 6)) for x in bucket)))


from decimal import Decimal
(n, k) = map(int, input().split())
mat = []
ans = [0] * k
for i in range(n):
	row = list(map(int, input().split()))
	mat.append(row)
dp = [[0] * n for _ in range(k)]
sums = [0] * n
for i in range(n):
	sums[i] = sum(mat[i])
for col in range(n):
	dp[0][col] = mat[0][col] / sums[0]
for row in range(1, n):
	for col in range(k):
		a = dp[row - 1][col] * (mat[row][col] + 1) / (sums[row] + 1)
		b = (1 - dp[row - 1][col]) * mat[row][col] / (sums[row] + 1)
		dp[row][col] = dp[row - 1][col] * (mat[row][col] + 1) / (sums[row] + 1) + (1 - dp[row - 1][col]) * mat[row][col] / (sums[row] + 1)
		dp[row][col] = round(dp[row][col], 6)
print(' '.join(map(str, dp[n - 1])))