#!/usr/bin/python3
from sys import argv
from math import exp, cos

M  = 6
Qm = 1.001 - (2 * M * 0.001)
n = int(argv[1])
x = float(argv[2])
f = lambda i, j, n: (Qm ** (i + j)) + (0.1 * (j - i)) if i != j else (Qm - 1) ** (i + j)
g = lambda i, n, x: x * exp(x / i) * cos(x / i)

def buildMtx():
    return ([[f(i + 1, j + 1, n) for j in range(n)] for i in range(n)], [g(i + 1, n, x) for i in range(n)])
    
A, f = buildMtx()
for i in A:
    print(" ".join(map(str, i)))
print(" ".join(map(str, f)))
