n fish, numbered from 1 to n, live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability aij, and the second will eat up the first with the probability aji = 1 - aij. The described process goes on until there are at least two fish in the lake. For each fish find out the probability that it will survive to be the last in the lake.

Input

The first line contains integer n (1 ≤ n ≤ 18) — the amount of fish in the lake. Then there follow n lines with n real numbers each — matrix a. aij (0 ≤ aij ≤ 1) — the probability that fish with index i eats up fish with index j. It's guaranteed that the main diagonal contains zeros only, and for other elements the following is true: aij = 1 - aji. All real numbers are given with not more than 6 characters after the decimal point.

Output

Output n space-separated real numbers accurate to not less than 6 decimal places. Number with index i should be equal to the probability that fish with index i will survive to be the last in the lake.

Examples

Input

2
0 0.5
0.5 0


Output

0.500000 0.500000 

Input

5
0 1 1 1 1
0 0 0.5 0.5 0.5
0 0.5 0 0.5 0.5
0 0.5 0.5 0 0.5
0 0.5 0.5 0.5 0


Output

1.000000 0.000000 0.000000 0.000000 0.000000

Difficulty: HARD
Tags: Dynamic programming

Bit manipulation

Probability
Skill types: Dynamic programming

Bit manipulation

Starter code:

Solutions:
import os
import sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	prob = []
	for _ in range(n):
		prob.append(list(map(float, input().split())))
	dp = [-1 for _ in range(1 << n)]
	ans = [0 for _ in range(n)]

	def move(mask, die):
		total = bin(mask).count('1')
		z = 0
		for i in range(n):
			if mask & 1 << i:
				z += prob[i][die]
		return z / (total * (total - 1) >> 1)

	def solve(mask):
		if mask == (1 << n) - 1:
			return 1
		if dp[mask] != -1:
			return dp[mask]
		ans = 0
		for i in range(n):
			if not mask & 1 << i:
				prev = solve(mask ^ 1 << i)
				ans += prev * move(mask ^ 1 << i, i)
		dp[mask] = ans
		return ans
	for i in range(n):
		ans[i] = '%.6f' % solve(1 << i)
	print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
input = stdin.readline

def count(n):
	value = 0
	while n:
		n &= n - 1
		value += 1
	return value

def nc2(n):
	return n * (n - 1) // 2

def answer():
	dp = [0] * (1 << n)
	dp[(1 << n) - 1] = 1
	for mask in range((1 << n) - 1, 0, -1):
		m = count(mask)
		if m == 1:
			continue
		p = 1 / nc2(m)
		for i in range(n):
			for j in range(n):
				if i == j:
					continue
				if mask >> i & 1 and mask >> j & 1:
					next_mask = mask ^ 1 << j
					dp[next_mask] += dp[mask] * p * a[i][j]
	for i in range(n):
		print(dp[1 << i], end=' ')
n = int(input())
a = [list(map(float, input().split())) for i in range(n)]
answer()
print()


n = int(input())
probs = list()
for i in range(n):
	probs.append(list(map(float, input().split())))
dp = [list([0 for i in range(1 << n)]) for i in range(n)]
dp[0][(1 << n) - 1] = 1
ak = [list() for i in range(n + 1)]
for i in range(1 << n):
	ak[bin(i).count('1')].append(i)
for k in range(1, n):
	for ele in ak[n - k + 1]:
		for j in range(n):
			if ele & 1 << j:
				for w in range(n):
					if ele & 1 << w and j != w:
						dp[k][ele - (1 << j)] += dp[k - 1][ele] * probs[w][j] / ((n - k + 1) * (n - k) / 2)
for i in range(n):
	print(dp[n - 1][1 << i], end=' ')
print()


import sys
input = sys.stdin.readline

def count_bits(x):
	cnt = 0
	for i in range(n):
		if 1 << i & x:
			cnt += 1
	return cnt
n = int(input())
a = [list(map(float, input().split())) for i in range(n)]
dp = [0 for i in range(1 << n)]
dp[-1] = 1
for mask in range((1 << n) - 1, -1, -1):
	val = count_bits(mask)
	total = val * (val - 1) // 2
	for i in range(n):
		if mask & 1 << i == 0:
			continue
		for j in range(n):
			if mask & 1 << j == 0 or i == j:
				continue
			dp[mask ^ 1 << j] += dp[mask] * a[i][j] / total
for i in range(n):
	print(dp[1 << i])


n = int(input())
b = []
for i in range(n):
	b.append(list(map(float, input().split())))
ma = 1 << n
dp = [0 for j in range(ma)]
dp[0] = 1
for mask in range(1, ma):
	l = n - bin(mask).count('1') + 1
	res = l * (l - 1) // 2
	for i in range(n):
		if mask & 1 << i:
			for j in range(n):
				if not mask & 1 << j:
					dp[mask] += dp[mask ^ 1 << i] * b[j][i] / res
ans = []
for i in range(n):
	ans.append(dp[ma - 1 - (1 << i)])
print(*ans)


n = int(input())
p = []
for i in range(n):
	la = list(map(float, input().split()))
	p.append(la)
full_bit = (1 << n) - 1
dp = [0] * full_bit + [1]
for i in range(full_bit, 0, -1):
	cunt = bin(i)[2:].count('1')
	if cunt == 1 or dp[i] == 0:
		continue
	mul = 1 / (cunt * (cunt - 1) >> 1)
	for x in range(n):
		if i & 1 << x == 0:
			continue
		for y in range(x + 1, n):
			if i & 1 << y == 0:
				continue
			dp[i - (1 << y)] += dp[i] * p[x][y] * mul
			dp[i - (1 << x)] += dp[i] * p[y][x] * mul
ans = []
for i in range(n):
	ans.append(dp[1 << i])
print(*ans)


import os, sys
from io import BytesIO, IOBase

def count(x):
	ans = 0
	while x:
		x &= x - 1
		ans += 1
	return ans

def main():
	n = int(input())
	a = [list(map(float, input().split())) for _ in range(n)]
	y = 1 << n
	dp = [0] * (y - 1) + [1]
	powe = [1 << i for i in range(n)]
	for i in range(y - 1, 0, -1):
		bit = count(i)
		prob = bit * (bit - 1) // 2
		for j in range(n):
			if not i & powe[j]:
				continue
			for x in range(n):
				if not i & powe[x]:
					continue
				dp[i - powe[x]] += dp[i] * a[j][x] * prob
				dp[i - powe[j]] += dp[i] * a[x][j] * prob
	z = sum((dp[1 << i] for i in range(n)))
	for i in range(n):
		print(dp[1 << i] / z, end=' ')
	print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
from array import array

def input():
	return sys.stdin.buffer.readline().decode('utf-8')
n = int(input())
prob = [tuple(map(float, input().split())) for _ in range(n)]
full_bit = (1 << n) - 1
dp = [0.0] * full_bit + [1.0]
for bit in range(full_bit, 0, -1):
	popcount = len([1 for i in range(n) if 1 << i & bit])
	if popcount == 1 or dp[bit] == 0.0:
		continue
	div = 1 / (popcount * (popcount - 1) >> 1)
	for i in range(n):
		if 1 << i & bit == 0:
			continue
		for j in range(i + 1, n):
			if 1 << j & bit == 0:
				continue
			dp[bit - (1 << j)] += dp[bit] * prob[i][j] * div
			dp[bit - (1 << i)] += dp[bit] * prob[j][i] * div
print(*(dp[1 << i] for i in range(n)))