Levko loves tables that consist of n rows and n columns very much. He especially loves beautiful tables. A table is beautiful to Levko if the sum of elements in each row and column of the table equals k.

Unfortunately, he doesn't know any such table. Your task is to help him to find at least one of them. 


-----Input-----

The single line contains two integers, n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 1000).


-----Output-----

Print any beautiful table. Levko doesn't like too big numbers, so all elements of the table mustn't exceed 1000 in their absolute value.

If there are multiple suitable tables, you are allowed to print any of them.


-----Examples-----
Input
2 4

Output
1 3
3 1

Input
4 7

Output
2 1 0 4
4 0 2 1
1 3 3 0
0 3 2 2



-----Note-----

In the first sample the sum in the first row is 1 + 3 = 4, in the second row — 3 + 1 = 4, in the first column — 1 + 3 = 4 and in the second column — 3 + 1 = 4. There are other beautiful tables for this sample.

In the second sample the sum of elements in each row and each column equals 7. Besides, there are other tables that meet the statement requirements.

Difficulty: EASY
Tags: Implementation

Constructive algorithms

Starter code:

Solutions:
(n, k) = map(int, input().split())
for i in range(0, n):
	for j in range(0, n):
		if i == j:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print()


(x, y) = map(int, input().split())
for i in range(x):
	for j in range(x):
		print(y if i == j else 0, end=' ')
	print()


(n, k) = list(map(int, input().split()))
p = []
a = [0] * n
for i in range(0, n):
	a[i] = k
	p.append(a)
	a = [0] * n
for i in range(0, n):
	w = ''
	for j in range(0, n):
		w = w + str(p[i][j]) + ' '
	print(w[:-1])


[n, k] = [int(i) for i in input().split()]
for x in range(n):
	for y in range(n):
		if x == y:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print()


from copy import deepcopy
(n, k) = map(int, input().split())

def fill_matrix(n):
	data = []
	q = [0] * n
	for i in range(n):
		data.append(deepcopy(q))
	return data

def E_matrix(matrix):
	for i in range(n):
		matrix[i][i] = k
matrix = fill_matrix(n)
E_matrix(matrix)
for row in matrix:
	sep = ' '
	for col in row:
		print(col, end=sep)
	print('')


[n, m] = map(int, input().split())
for i in range(n):
	print('0 ' * (n - i - 1) + str(m) + ' ' + '0 ' * (0 + i))


string = input()
numbers = string.split()
(a, b) = (int(numbers[0]), int(numbers[1]))
row = [0 for x in range(a - 1)]
row.append(b)
for x in range(a):
	print(' '.join(map(str, row[x:] + row[:x])))


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
from math import inf

def main():
	try:
		(n, m) = invr()
		a = [[0 for _ in range(n)] for __ in range(n)]
		for i in range(n):
			for j in range(n):
				if i == j:
					a[i][j] = m
		for i in range(n):
			print(*a[i], sep=' ')
	except Exception as e:
		print(e)
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 os
import sys
from io import BytesIO, IOBase
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
for i in range(n):
	for j in range(n):
		if i == j:
			print(k - n + 1, end=' ')
		else:
			print(1, end=' ')
	print()


def solution(l1):
	n = l1[0]
	k = l1[1]
	i = 0
	while i < n:
		c_out = ''
		j = 0
		while j < n:
			if j == i:
				c_out += str(k)
			else:
				c_out += str(0)
			j += 1
			if j != n:
				c_out += ' '
		print(c_out)
		i += 1

def answer():
	l1 = [int(x) for x in input().split()]
	solution(l1)
answer()


(n, k) = map(int, input().split())
for i in range(n):
	for j in range(i, n - 1):
		print(0, end=' ')
	print(k, end=' ')
	for j in range(n - i, n):
		print(0, end=' ')
	print()


(n, k) = list(map(int, input().split()))
for i in range(n):
	out = ''
	for j in range(n):
		if i == j:
			out += str(k) + ' '
		else:
			out += str(0) + ' '
	print(out.rstrip())


import string

def main_function():
	(n, k) = [int(i) for i in input().split(' ')]
	output_list = [[str(0) for i in range(n)] for i in range(n)]
	for i in range(n):
		output_list[i][i] = str(k)
	return '\n'.join([' '.join(i) for i in output_list])
print(main_function())


import sys

def main():
	(n, k) = map(int, sys.stdin.read().strip().split())
	return (' '.join((str(k // n + k % n * (i == j)) for j in range(n))) for i in range(n))
print(*main(), sep='\n')


(n, k) = map(int, input().split())
for i in range(n):
	result = ''
	for j in range(n):
		if i == j:
			result += str(k)
		else:
			result += str(0)
		result += ' '
	print(result)


(n, k) = map(int, input().split())
for i in range(n):
	l = []
	for j in range(n):
		if i == j:
			l.append(k)
		else:
			l.append(0)
	print(*l)


(n, k) = map(int, input().split())
table = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
	for j in range(n):
		if i == j:
			table[i][j] = k
for row in table:
	print(' '.join(list(map(str, row))))


(x, y) = [int(x) for x in input('').split()]
for i in range(x):
	l = [0] * x
	l[i] = y
	print(*l)


n = input().split()
k = int(n[1])
n = int(n[0])
cv = k
x = 0
s = []
while x < n:
	s.append(int(0))
	x = x + 1
x = 0
while cv != 0:
	s[x] = s[x] + 1
	x = x + 1
	cv = cv - 1
	if x == n:
		x = 0
x = 0
y = 0
while x < n:
	cv = x
	while y < n:
		print(s[cv], end=' ')
		cv = cv + 1
		y = y + 1
		if cv >= n:
			cv = 0
	print('')
	x = x + 1
	y = 0


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	(n, k) = read_ints()
	for i in range(n):
		A = [0] * n
		A[i] = k
		print_nums(A)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
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')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


(n, k) = map(int, input().split())
a = []
b = []
for i in range(n):
	b = []
	for j in range(n):
		if i == j:
			b.append(k)
		else:
			b.append(0)
	a.append(b)
for i in range(n):
	for j in range(n):
		print(a[i][j], '', end='')
	print()


(n, k) = list(map(int, input().split()))
for i in range(n):
	print(i * '0 ', k, (n - i - 1) * ' 0', sep='')


(n, k) = map(int, input().split())
A = [[0] * n for _ in range(n)]
for i in range(n):
	A[i][i] = k
for row in A:
	print(*row)


(n, k) = map(int, input().split())
for i in range(n):
	c = [0] * n
	c[i] = k
	print(*c)


(n, k) = map(int, input().strip().split())
row = [k] + [0] * (n - 1)
for _ in range(n):
	row.append(row.pop(0))
	print(*row)


import math

def main():
	(n, k) = map(int, input().split())
	for row in range(1, n + 1):
		print(' '.join(map(str, (k if val == row else 0 for val in range(1, n + 1)))))
main()


import sys
import math
import bisect

def main():
	(n, m) = map(int, input().split())
	A = []
	for i in range(n):
		A.append([0] * n)
	for i in range(n):
		for j in range(n):
			if i == j:
				A[i][j] = m
	for i in range(n):
		print(' '.join(list((str(a) for a in A[i]))))
main()


(s, r) = map(int, input().split())
for i in range(s):
	for j in range(s):
		print(r if i == j else 0, end=' ')
	print()


(n, k) = list(map(int, input().split()))
md = k - (n - 1)
for i in range(n):
	for j in range(n):
		if i == j:
			print(md, end=' ')
		else:
			print(1, end=' ')
	print()


(n, m) = map(int, input().split())
x = []
for i in range(n):
	for j in range(n):
		if i == j:
			print(m, end=' ')
		else:
			print(0, end=' ')
	print()


(n, k) = map(int, input().split())
l = [k]
for i in range(n - 1):
	l.append(0)
for i in range(n):
	print(*l)
	x = l[n - 1]
	del l[n - 1]
	l.insert(0, x)


(n, k) = map(int, input().split())
mat = [[0] * n for i in range(n)]
for i in range(n):
	mat[i][i] = k
for x in mat:
	print(*x)


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
(n, k) = RI()
l = [[0] * n for i in range(n)]
p = k - (n - 1)
for i in range(n):
	j = i
	for k in range(n - 1):
		l[i][(j + k) % n] = 1
	l[i][(j + n - 1) % n] = p
for i in range(n):
	print(*l[i], sep=' ')


(n, m) = map(int, input().split())
arr = list()
it = n - 1
for i in range(0, n):
	for k in range(0, n):
		if k != it:
			arr.append(1)
		elif k == it:
			arr.append(m - n + 1)
	it -= 1
	print(' '.join(map(str, arr)))
	arr.clear()


(n, k) = map(int, input().split())
a = [[k, 0][i != j] for i in range(n) for j in range(n)]
print(*a)


import sys
import os

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = 1
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	if n == 1:
		print(k)
		continue
	for i in range(n):
		l = '0 ' * (i - 0) + str(k) + ' 0' * (n - 1 - i)
		print(l)


__author__ = 'Dilshod'
(n, k) = list(map(int, input().split()))
arr = []
for i in range(n):
	arr += [[0] * i + [k] + [0] * (n - 1 - i)]
for i in arr:
	print(*i, sep=' ')


(n, k) = map(int, input().split())
ans = [[0] * n for i in range(n)]
q = 0
for i in range(n):
	for j in range(n):
		if j == q:
			ans[i][j] = k
	q += 1
for i in range(n):
	print(*ans[i])


(n, k) = map(int, input().split())
s = ['0' for _ in range(n)]
for i in range(1):
	for j in range(n):
		s[j] = str(k)
		s = ' '.join(s)
		print(s)
		s = ['0' for _ in range(n)]


(n, k) = map(int, input().split())
a = [[0] * n for x in range(n)]
for i in range(len(a)):
	for j in range(len(a[i])):
		if j == i:
			a[i][j] = k
for x in a:
	st = ''
	for y in x:
		st += str(y) + ' '
	print(st)


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


(n, k) = list(map(int, input().split()))
defaultVal = k // n
for i in range(n):
	arr = [defaultVal] * n
	arr[i] = k - (n - 1) * defaultVal
	print(*arr)


def main():
	[n, k] = [int(_) for _ in input().split()]
	row = ['0'] * n
	row[0] = str(k)
	for i in range(n):
		print(' '.join(row))
		row[i] = '0'
		if i < n - 1:
			row[i + 1] = str(k)
main()


(n, k) = map(int, input().split())
for i in range(n):
	a = n * [0]
	for j in range(n):
		if j == n - i - 1:
			a[j] = k
	print(*a, sep=' ')


(n, k) = map(int, input().split())
if k < n:
	Mat = [[1 for q in range(n)] for i in range(n)]
	rem_zero = n - k
	for q in range(n):
		for j in range(n):
			if q + j == n - 1:
				for i in range(rem_zero):
					Mat[q][j - i] = 0
else:
	Mat = [[1 for q in range(n)] for i in range(n)]
	rem = k - (n - 1)
	for q in range(n):
		for j in range(n):
			if q + j == n - 1:
				Mat[q][j] = rem
for j in Mat:
	print(*j)


(n, k) = [int(x) for x in input().split()]
for i in range(n):
	tmp = [0] * i + [k] + [0] * (n - i - 1)
	print(*tmp, sep=' ')


(r, c) = input().split()
r = int(r)
c = int(c)
for i in range(r):
	for j in range(r):
		if i == j:
			print(c, end=' ')
		elif j == r - 1:
			print('0')
		else:
			print('0', end=' ')


(n, m) = map(int, input().split())
for i in range(n):
	for j in range(n):
		if i == j:
			print(m, end=' ')
		elif i != j and j < n - 1:
			print(0, end=' ')
		else:
			print(0)


(n, k) = map(int, input().split())
ans = []
for i in range(n):
	x = []
	r = k
	for j in range(n):
		if i == j:
			x.append(k)
		else:
			x.append(0)
	ans.append(x)
for i in range(n):
	print(*ans[i])


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


def solution():
	(n, k) = map(int, input().split())
	arr = [[0 for i in range(n)] for j in range(n)]
	for i in range(n):
		for j in range(n):
			if i == j:
				arr[i][j] = k
	for i in range(n):
		print(*arr[i])
	return
solution()


(n, p) = map(int, input().split())
for i in range(n):
	arr = []
	for j in range(n):
		arr.append('0')
	arr[i] = str(p)
	answer = ' '.join(arr)
	print(answer)


get = lambda : list(map(int, input().split()))
(n, m) = get()
for i in range(n):
	c = ['0'] * n
	c[i] = str(m)
	print(' '.join(c))


(size, k) = map(int, input().split())
for r in range(size):
	for c in range(size):
		if r == c:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print()


(n, m) = map(int, input().split())
for i in range(n):
	ans = [0] * n
	ans[i] = m
	print(*ans)


(x, y) = map(int, input().split())
s = 0
z = []
for i in range(x):
	for j in range(x):
		if j == x - 1:
			if i == j:
				print(int(y / x) + y % x)
			else:
				print(int(y / x))
		elif i == j:
			print(int(y / x) + y % x, end=' ')
		else:
			print(int(y / x), end=' ')


(n, s) = map(int, input().split())
arr = [0] * (n - 1)
arr.append(s)
for r in range(n):
	for c in range(r, r + n):
		print(arr[c % n], end=' ')
	print()


temp = list(map(int, input().split()))
n = temp[0]
k = temp[1]
temp = []
my_list = []
for x in range(n):
	temp = [0] * n
	temp[x] = k
	my_list.append(temp)
for x in range(n):
	for y in range(n):
		print(my_list[x][y], end=' ')
	print()


def genstring(num, length, index):
	return ('0 ' * index + str(num) + ' ' + '0 ' * (length - index)).strip()
(a, b) = map(int, input().split(' '))
for t in range(a):
	print(genstring(b, a - 1, t))


(n, k) = map(int, input().split())
for i in range(n):
	temp = [0] * n
	temp[i] = k
	print(*temp, sep=' ')


line = list(map(int, input().split()))
n = line[0]
k = str(line[1])
for i in range(0, n):
	stri = ''
	for j in range(0, n):
		if i != j:
			stri = stri + '0 '
		else:
			stri = stri + k + ' '
	print(stri[:-1])


(n, k) = map(int, input().split())
matrix = [[0 for _ in range(n)] for _ in range(n)]
for (i, row) in enumerate(matrix):
	row[i] = k
	print(*row)


a = input().split()
n = int(a[0])
x = int(a[1]) - n + 1
for i in range(n):
	for j in range(n):
		if i == j:
			print(x, end=' ')
		else:
			print(1, end=' ')
	print()


(n, k) = map(int, input().split())
A = [['0' for i in range(n)] for j in range(n)]
for i in range(n):
	A[i][i] = str(k)
for row in A:
	print(' '.join(row))


(m, n) = input().split()
m = int(m)
n = int(n)
l = []
l.append(n)
i = 0
while len(l) != m:
	l.append(0)
while m != 0:
	print(*l)
	l = l[1:] + l[:1]
	m = m - 1


(n, k) = [int(x) for x in input().split(' ')]
i = 0
for x in range(n):
	temp = ['0' for y in range(n)]
	temp[i] = str(k)
	print(' '.join(temp))
	i += 1


(a, b) = map(int, input().split())
for i in range(a):
	for j in range(a):
		if i == j:
			print(b, end=' ')
		else:
			print(0, end=' ')
	print()


def main():
	(n, k) = input().split()
	n = int(n)
	for i in range(n):
		print('0 ' * i + k + ' 0' * (n - i - 1))
main()


(n, k) = map(int, input().split())
for i in range(n):
	print(' '.join(['0'] * i + [str(k)] + ['0'] * (n - i - 1)))


def get_row(req_sum, n):
	each = int(req_sum / n)
	current_sum = each * (n - 1)
	result = []
	for i in range(n - 1):
		result.append(each)
	result.append(req_sum - current_sum)
	return result

def print_table(l):
	shift = 0
	for i in range(0, len(l)):
		result = ''
		for j in range(0, len(l)):
			result += str(l[(j + shift) % len(l)])
			if j < len(l) - 1:
				result += ' '
		print(result)
		shift += 1

def main():
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	print_table(get_row(k, n))
main()


[n, k] = map(int, input().split())
a = k // n
b = k - a * (n - 1)
for j in range(n):
	for i in range(j):
		print(a, end=' ')
	print(b, end=' ')
	for j in range(n - j - 1):
		print(a, end=' ')
	print()


import sys
input = sys.stdin.readline
(n, k) = [int(i) for i in input().split()]
for i in range(n):
	for j in range(n):
		print([0, k][i == j], end=' ')
	print()


(n, k) = [int(x) for x in input().split(' ')]
for i in range(n):
	a = [0] * n
	a[i] = k
	print(*a)


(m, n) = map(int, input().split())
a = []
for i in range(m):
	a.append([0] * m)
for i in range(m):
	for j in range(m):
		if i == j:
			a[i][j] = n
for i in range(m):
	print(*a[i])


IL = lambda : list(map(int, input().split()))
(n, k) = IL()
for i in range(n):
	r = [0] * n
	r[i] = k
	print(*r)


import time
import math
from sys import stdin, stdout

def I():
	return int(stdin.readline())

def In():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def Si():
	return sorted(list(map(int, stdin.readline().split())))

def Si():
	return sorted(list(map(int, stdin.readline().split())), reverse=True)

def P(x):
	return stdout.write(str(x))

def Pi(x, y):
	return stdout.write(str(x) + ' ' + str(y))

def solve():
	(n, k) = In()
	for i in range(n):
		for j in range(n):
			P(k if i == j else '0')
			P(' ')
		P('\n')
solve()


(d, v) = map(int, input().split())
list1 = [v] + [0] * (d - 1)
ans = ''
for i in range(d):
	for e in range(d):
		ans += str(list1[e]) + ' '
		if e == d - 1:
			ans += '\n'
			list1.insert(0, list1.pop())
print(ans)


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append([0] * n)
for i in range(n):
	l[i][i] = k
for i in l:
	for j in i:
		print(j, end=' ')
	print('\n')


(n, k) = map(int, input().split())
elementValue = k // n
row = [elementValue] * n
row[0] += k % n
print(*row)
for i in range(n - 1):
	(row[i], row[i + 1]) = (row[i + 1], row[i])
	print(*row)


s1 = input()
s = s1.split()
n = int(s[0])
k = int(s[1])
for row in range(n):
	for col in range(n):
		if row == col:
			print(k, end=' ')
		else:
			print('0', end=' ')
	print()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
(n, k) = map(int, input().split())
ans = [[k // n for i in range(n)] for i in range(n)]
if k % n != 0:
	for i in range(n):
		ans[i][i] = k - (n - 1) * (k // n)
for row in ans:
	print(' '.join(map(str, row)))


(n, k) = map(int, input().split())
for x in range(n):
	a = [0 for x in range(n)]
	a[x] = k
	for y in range(n):
		if y != n - 1:
			print(a[y], end=' ')
		else:
			print(a[y])


from itertools import repeat
(n, k) = map(int, input().split())
m = k // n
r = k % n
for i in range(n):
	print(*repeat(m, i), m + r, *repeat(m, n - i - 1))


import sys

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

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, k) = rinput()
a = []
for i in range(n):
	for j in range(n):
		if i == j:
			a.append(k)
		else:
			a.append(0)
for i in range(0, n * n + 1, n):
	print(*a[i:n + i])


(n, k) = map(int, input().split())
z = k + 1 - n
for i in range(n):
	for j in range(n):
		if i == j:
			print(z, end=' ')
		else:
			print(1, end=' ')
	print()


x = 0
(n, k) = map(int, input().split())
k -= n - 1
for i in range(n):
	for z in range(n):
		if z == x:
			print(k, end=' ')
		else:
			print('1', end=' ')
	x += 1
	print()


x = list(map(int, input().split()))
for i in range(x[0]):
	print(*'0' * i, x[1], *'0' * (x[0] - (i + 1)), sep=' ')


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

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')
(n, k) = map(int, input().split(' '))
ans = [[1] * n for i in range(n)]
for i in range(n):
	ans[i][i] = k - n + 1
for i in range(n):
	print(*ans[i])


napis = input().split()
ileRzedow = int(napis[0])
jakaSuma = int(napis[1])
for x in range(ileRzedow):
	nowyNapis = '0 ' * x + '{0} '.format(jakaSuma) + '0 ' * (ileRzedow - 1 - x)
	print(nowyNapis)


(n, k) = map(int, input().split())
a = [0] * n
i = 0
while i < n:
	a[i] = k
	print(*a)
	a = [0] * n
	i = i + 1


(n, k) = map(int, input().split())
num = k - n + 1
for i in range(n):
	for t in range(i):
		print(1, end=' ')
	print(num, end=' ')
	for j in range(n - i - 1):
		print(1, end=' ')
	print('')


(N, k) = map(int, input().split())
ind = 0
for i in range(N):
	for j in range(N):
		if j != N - 1:
			if j == i:
				print(k, end=' ')
			else:
				print(0, end=' ')
		elif j == i:
			print(k)
		else:
			print(0)


from itertools import permutations
(n, k) = map(int, input().split())
arr = []
count = 0
for m in range(n):
	lst = [0] * n
	lst[count] = k
	count += 1
	arr.append(lst)
for x in arr:
	print(*x)


a = [int(x) for x in input().strip().split(' ')]
if a[1] >= a[0]:
	temp = a[1] - a[0] + 1
	for i in range(1, a[0] + 1):
		for j in range(1, a[0] + 1):
			if i == j:
				print(temp, end=' ')
			else:
				print(1, end=' ')
		print()
else:
	for i in range(1, a[0] + 1):
		for j in range(1, a[0] + 1):
			if i == j:
				print(a[1], end=' ')
			else:
				print(0, end=' ')
		print()


(n, k) = map(int, input().split())
s = ['0' for _ in range(n)]

def get_pattern(s, n, k):
	out = ''
	for i in range(1):
		for j in range(n):
			s[j] = str(k)
			out += ' '.join(s) + '\n'
			s = ['0' for _ in range(n)]
	return out
res = get_pattern(s, n, k)
print(res)


(N, K) = [int(x) for x in input().split()]
for i in range(1, N + 1):
	for j in range(1, N + 1):
		if i == j:
			print(K, end=' ')
		else:
			print(0, end=' ')
	print('')


def rotate(a, n):
	x = a[0]
	b = []
	for i in range(1, n):
		b.append(a[i])
	b.append(x)
	return b
(n, k) = map(int, input().split())
a = []
i = n
while i >= 1:
	x = k // i
	k = k - x
	a.append(x)
	i -= 1
b = []
for i in range(n):
	b.append(a)
	a = rotate(a, n)
for i in range(n):
	for j in range(n):
		print(b[i][j], end=' ')
	print()


(n, k) = map(int, input().split())
d = k - (n - 1)
for i in range(n):
	row = [1] * i + [d] + [1] * (n - i - 1)
	print(' '.join(map(str, row)))


(n, k) = map(int, input().split())
(t, c) = (k - n + 1, 0)
for i in range(n):
	t1 = ['1'] * n
	t1[c] = str(t)
	c += 1
	print(' '.join(t1))


import itertools
import math
import random
import time

def timer(f):

	def tmp(*args, **kwargs):
		t = time.time()
		res = f(*args, **kwargs)
		print('Время выполнения функции: %f' % (time.time() - t))
		return res
	return tmp

def genArray(length, lower, upper):
	return [random.randint(lower, upper) for i in range(length)]
(n, k) = map(int, input().split(' '))
s = ''
for i in range(n):
	for j in range(n):
		if i == j:
			s += str(k) + ' '
		else:
			s += '0 '
	s += '\n'
print(s)


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

def ip():
	return int(sys.stdin.readline())

def sip():
	return sys.stdin.readline()

def mip():
	return map(int, sys.stdin.readline().split())

def mips():
	return map(str, sys.stdin.readline().split())

def lip():
	return list(map(int, sys.stdin.readline().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
(a, b) = mip()
for i in range(a):
	lst = [0] * a
	lst[i] = b
	print(*lst)


class CodeforcesTask361ASolution:

	def __init__(self):
		self.result = ''
		self.n_k = []

	def read_input(self):
		self.n_k = [int(x) for x in input().split(' ')]

	def process_task(self):
		res = []
		for x in range(self.n_k[0]):
			line = [0] * self.n_k[0]
			line[x] = self.n_k[1]
			res.append(' '.join([str(y) for y in line]))
		self.result = '\n'.join(res)

	def get_result(self):
		return self.result
Solution = CodeforcesTask361ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


3

def readln():
	return tuple(map(int, input().split()))
(n, k) = readln()
for i in range(n):
	print(*[k if i == j else 0 for j in range(n)])


def main():
	(n, k) = input().split()
	n = int(n)
	row = ['0'] * n
	for i in range(n):
		row[i] = k
		print(' '.join(row))
		row[i] = '0'
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	(n, k) = LI()
	rr = [[0] * n for _ in range(n)]
	for i in range(n):
		rr[i][i] = k
	return JAA(rr, '\n', ' ')
print(main())


q = 0
s = input()
s = s.split()
n = int(s[0])
k = int(s[1])
l = []
sum = 0
for i in range(n + 1):
	if i != 0:
		l.append(i)
		sum += i
k = k - sum
i = 0
while k > 0 and i < n:
	if l[i] + k > 1000:
		k = k - 1000 + l[i]
		l[i] = 1000
	else:
		l[i] = l[i] + k
		k = 0
	i += 1
i = 0
while k < 0 and i < n:
	if l[i] + k < -1000:
		k = k + 1000 + l[i]
		l[i] = -1000
	else:
		l[i] = l[i] + k
		k = 0
	i += 1
sum = 0
for i in range(len(l)):
	q = 0
	j = i
	while q < len(l):
		if j == len(l):
			j = 0
		print(l[j], end=' ')
		q += 1
		j += 1
	sum += l[i]
	print()


(n, k) = map(int, input().split())
m = k // n
a = [[0] * n] * n
l = k % n
for i in range(n):
	for j in range(n):
		if i == j:
			a[i][j] = l + m
		else:
			a[i][j] = m
	print(*a[i])


(n, k) = [int(i) for i in input().split()]
a = [[0] * n for i in range(n)]
for i in range(n):
	for j in range(n):
		if i == j:
			a[i][j] = k
for elem in a:
	print(*elem)


def solve(n, k):
	for i in range(n):
		s = []
		for j in range(n):
			if i == j:
				s.append(str(k))
			else:
				s.append(0)
		print(' '.join(map(str, s)))

def main():
	(n, k) = list(map(int, input().split()))
	solve(n, k)
main()


import sys
import math
(n, k) = [int(x) for x in sys.stdin.readline().split()]
for i in range(n):
	t = []
	for j in range(n):
		if j == i:
			t.append(str(k))
		else:
			t.append(str(0))
	print(' '.join(t))


(a, b) = [int(i) for i in input().split()]
for i in range(a):
	print('0 ' * i, b, ' 0' * (a - i - 1), sep='')


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, m) = LI()
	a = []
	for i in range(n):
		x = m // (n - i)
		a.append(x)
		m -= x
	for _ in range(n):
		print(' '.join((str(b) for b in a)))
		a = a[1:] + [a[0]]
main()


[n, k] = map(int, input().split())
if n == 1:
	print(k)
else:
	num1 = k // (n - 1)
	remainder = k - (n - 1) * num1
	for i in range(n):
		for j in range(i):
			print(num1, end=' ')
		print(remainder, end=' ')
		for k in range(n - i - 1):
			print(num1, end=' ')
		print()


(n, k) = map(int, input().split())
ans = []
if k <= n:
	for i in range(n):
		row = [0] * n
		row[i] = k
		ans += [row]
else:
	for i in range(n):
		row = [1] * n
		row[i] = k - (n - 1)
		ans += [row]
for a in ans:
	for j in a:
		print(j, end=' ')
	print()


s = [int(n) for n in input().split()]
for n in range(s[0]):
	for k in range(s[0]):
		if n == k:
			print(s[1], end=' ')
		else:
			print(0, end=' ')
	print()


(n, k) = map(int, input().split())
temp = k
lst = []
if (n - 1) * n // 2 > k:
	lst = [k] + [0] * (n - 1)
else:
	for i in range(n):
		if i == n - 1:
			lst.append(max(0, temp))
		else:
			lst.append(i)
		temp -= i
for i in range(n):
	print(*lst)
	t = lst.pop(0)
	lst.append(t)


i = input().split()
(n, k) = (int(i[0]), int(i[1]))
d = 0
mat = []
last_i = -1
for i in range(n):
	for j in range(n):
		if j == d and i != last_i:
			print(k, end=' ')
			last_i = i
			d += 1
		else:
			print(0, end=' ')
	print()


def inp():
	return map(int, input().split())

def print_arr(arr):
	print(*arr, sep=' ')

def fill_arr(n):
	return [0 for x in range(n)]
(n, k) = inp()
m = fill_arr(n)
m[0] = k
for i in range(n):
	print_arr(m)
	if i < n - 1:
		(m[i], m[i + 1]) = (m[i + 1], m[i])


(n, k) = list(map(int, str(input()).strip().split()))
for i in range(n):
	for j in range(n):
		if j == i:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print('')


(n, k) = map(int, input().split())
for x in range(n):
	for y in range(n):
		print(0 if x != y else k, sep=' ')
	print()


import math
line = input()
integers = [int(i) for i in line.split()]
n = integers[0]
k = integers[1]
for i in range(n):
	if n - i - 2 != -1:
		print((str(0) + ' ') * i + str(k) + ' ' + (str(0) + ' ') * (n - i - 2) + str(0))
	else:
		print((str(0) + ' ') * i + str(k))


(x, y) = map(int, input().split())
d = 0
for i in range(x):
	for j in range(x):
		if j == d:
			print(y, end=' ')
		else:
			print(0, end=' ')
	d += 1
	print(end='\n')


import math
import pprint
(n, k) = map(int, input().split())
for row in range(n):
	for col in range(n):
		if row == col:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print()


(n, k) = [int(x) for x in input().split(' ')]
for i in range(n):
	print((n - i - 1) * '0 ' + str(k) + i * ' 0')


(n, k) = map(int, input().split(' '))
m = []
for i in range(n):
	m.append([])
	for j in range(n):
		m[i].append(None)
if k == 1000:
	for i in range(n):
		for j in range(n):
			if m[i][j] is None:
				m[i][j] = 0
			if i == j:
				m[i][j] = 999
				m[i][(j + 1) % n] = 1
else:
	for i in range(n):
		for j in range(n):
			if i == j:
				m[i][j] = k
			else:
				m[i][j] = 0
for i in m:
	print(' '.join((str(z) for z in i)))


(n, k) = str(input()).split()
n = int(n)
k = int(k)
for i in range(n):
	line = list()
	for j in range(i):
		line.append('0')
	line.append(str(k))
	for j in range(i + 1, n):
		line.append('0')
	print(' '.join(line))


(a, b) = map(int, input().split())
for i in range(a):
	c = [0] * a
	c[i] = b
	print(*c)


(n, k) = [int(x) for x in input().split()]
tabla = []
resto = 0
for x in range(n):
	row = []
	for y in range(n):
		row.append(0)
	tabla.append(row)
for x in range(n):
	for y in range(n):
		if x == y:
			tabla[x][y] = k
for x in tabla:
	print(*x)


(n, m) = map(int, input().split())
if n == m:
	for i in range(n):
		for j in range(n):
			print(1, end=' ')
		print()
elif n > m:
	temp = n - 1
	for i in range(n):
		for j in range(n):
			if n > i + j >= m or 2 * temp - (temp - m - 1) <= i + j <= 2 * temp:
				print(0, end=' ')
			else:
				print(1, end=' ')
		print()
else:
	present = n - 1
	for i in range(n):
		for j in range(n):
			if j == present:
				print(m - n + 1, end=' ')
			else:
				print(1, end=' ')
		present -= 1
		print()


(n, k) = map(int, input().split())
s = [[0 for i in range(n)] for j in range(n)]
d = []
for i in range(n):
	s[i][i] = k
	d.append(s[i])
for i in d:
	print(*i)


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


def main():
	(n, k) = map(int, input().split())
	ans = [[0] * n for _ in range(n)]
	for i in range(n):
		ans[i][i] = k
	for row in ans:
		print(*row)
main()


(n, k) = map(int, input().split())
v = k - (n - 1)
t = list()
for i in range(n):
	t.append([1 if i + c + 1 != n else v for c in range(n)])
for n in t:
	print(' '.join((str(x) for x in n)))


def lf(n):
	c = 0
	while n > 0:
		if n % 10 == 4 or n % 10 == 7:
			c += 1
		n = n // 10
	return c

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
(n, k) = mi()
a = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
	a[i][i] = k
for i in range(n):
	print(*a[i])


arr = input().split()
n = int(arr[0])
k = arr[1]
for i in range(n):
	str = ''
	for j in range(n):
		if i == j:
			str += k
		else:
			str += '0'
		str += ' '
	print(str)


(n, k) = list(map(int, input().split()))
p = [[0 for j in range(n)] for j in range(n)]
for i in range(n):
	p[i][i] = k
for i in range(n):
	print(*p[i])


def main():
	(n, k) = map(int, input().split())
	l = ['0'] * n
	s = str(k)
	for i in range(n):
		l[i] = s
		print(' '.join(l))
		l[i] = '0'
main()


(n, k) = map(int, input().split())
if k < n:
	done = [0] * (n - k) + [1] * k
	for off_set in range(n):
		for abcd in range(n):
			print(done[(off_set + abcd) % n])
		print()
elif k == n:
	for _ in range(n):
		for a in range(n):
			print(1, end=' ')
		print()
else:
	biggo = k - n + 1
	for biggo_pos in range(n):
		for i in range(biggo_pos):
			print(1, end=' ')
		print(biggo, end=' ')
		for i in range(biggo_pos, n - 1):
			print(1, end=' ')
		print()


def tables(n, k):
	ans = []
	for i in range(n):
		tmp = [0] * n
		tmp[i] = k
		ans.append(tmp)
	return ans
(n, k) = list(map(int, input().split()))
ret = tables(n, k)
for i in ret:
	print(*i)


from array import *
(n, k) = map(int, input().split())
ar = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
	ar[i][i] = k
for i in range(n):
	for j in range(n):
		print(ar[i][j], end=' ')
	print()


(n, k) = map(int, input().split())
for i in range(n):
	for j in range(n):
		print('0' if i is not j else str(k), end=' ')
	print()


import sys
(n, k) = map(int, sys.stdin.readline().split(' '))
for i in range(n):
	line = [0] * n
	line[i] = k
	sys.stdout.write('{}\n'.format(' '.join(map(str, line))))


(n, k) = [int(x) for x in input().split()]
for i in range(n):
	for j in range(n):
		if j != i:
			print('0', end=' ')
		else:
			print(str(k), end=' ')
	print('\n', end='')


from sys import stdout
(n, k) = map(int, input().split())
for i in range(n):
	for j in range(n):
		stdout.write(str(k) + ' ' if i == j else '0 ')
	stdout.write('\n')


l = lambda : map(int, input().split())
(n, k) = l()
for i in range(n):
	print('0 ' * i + str(k), '0 ' * (n - 1 - i))


n = list(map(int, input().split(' ')))
k = n[1]
for i in range(n[0]):
	for j in range(n[0]):
		A = [0] * n[0]
		A[i] = k
		A = map(str, A)
		A = ' '.join(A)
	print(A)


(n, k) = map(int, input().split())
l = []
for i in range(n):
	l.append(k - n + 1) if i == n - 1 else l.append(1)
for i in range(n):
	j = i
	while j < n:
		print(l[j], end=' ')
		j += 1
	j = 0
	while j < i:
		print(l[j], end=' ')
		j += 1
	print('\r')


import sys
inf = float('inf')

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, k) = get_ints()
mat = [[0 for i in range(n)] for j in range(n)]
value = k - n + 1
for i in range(n):
	for j in range(n):
		if i == j:
			mat[i][j] = value
		else:
			mat[i][j] = 1
for i in mat:
	print(*i)


(n, k) = input().split()
y: int = 0
ans: list = []
while int(y) < int(n):
	for x in range(int(n)):
		if x == y:
			ans.append(k)
		else:
			ans.append(0)
	y = int(y) + 1
	print(*ans)
	ans.clear()


z = list(map(int, input().split()))
s = str(z[1])
for i in range(z[0] - 1):
	s += ' 0'
s = s.split(' ')
for i in range(z[0]):
	if i == z[0] - 1:
		i -= 1
	print(' '.join(s))
	(s[i], s[i + 1]) = (s[i + 1], s[i])


(n, k) = input().split()
(n, k) = (int(n), int(k))
for i in range(n):
	for j in range(n):
		if i == j:
			print(k, end=' ')
		elif j == n - 1:
			print(0)
		else:
			print(0, end=' ')


(size, num) = map(int, input().split())
ans = []
for x in range(size):
	ans.append([0] * size)
for (index, x) in enumerate(ans):
	x[index] = num
	print(*x)


(n, m) = map(int, input().split())
for i in range(n):
	a = [0 for i in range(n)]
	a[i] = m
	print(' '.join(map(str, a)))


l = list(map(int, input().split()))
for i in range(l[0]):
	for j in range(l[0]):
		k = 0
		if i == j:
			k = l[1]
		print(k, end=' ')
	print()


import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	(n, k) = read()
	for i in range(n):
		for j in range(n):
			if i == j:
				print([k // n, k % n + k // n][k % n != 0], end=[' ', '\n'][j == n - 1])
			else:
				print(k // n, end=[' ', '\n'][j == n - 1])
solve()


(n, k) = map(int, input().split())
for i in range(n):
	temp = [0] * n
	temp[i] = k
	print(' '.join((str(temp[j]) for j in range(n))))


def levko_and_table(n_int: int, k_int: int) -> list:
	row_numbers_list = [0] * n_int
	quotient_int = k_int // n_int
	reminder_int = k_int % n_int
	table = []
	for i in range(quotient_int):
		for j in range(n_int):
			row_numbers_list[j] += 1
	for j in range(reminder_int):
		row_numbers_list[j] += 1
	table.append(row_numbers_list)
	for i in range(1, n_int):
		table.append(row_numbers_list[i:] + row_numbers_list[:i])
	for i in range(n_int):
		print(*table[i])
	return table
(n, k) = list(map(int, input().split()))
levko_and_table(n, k)


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if i == j:
			stdout.write(str(k))
		else:
			stdout.write('0')
		if j == n:
			stdout.write('\n')
		else:
			stdout.write(' ')


integer = int
string = str
length = len

def main():
	(n, k) = list(map(integer, input().split()))
	for i in range(n):
		temp = [0] * n
		temp[i] = k
		print(*temp)
main()


(n, k) = map(int, input().split())
if k % n == 0:
	p = k // n
	for i in range(n):
		for j in range(n):
			print(p, end=' ')
		print()
else:
	p = k // n
	A = []
	for i in range(n):
		A.append(p)
	A[-1] += k % n
	for i in range(n):
		for j in range(n):
			print(A[(j + i) % n], end=' ')
		print()


a = input().split()
n = int(a[0])
k = int(a[1])
ans = ''
for i in range(n):
	ans = ''
	for j in range(n):
		if i == j:
			ans += str(k) + ' '
		else:
			ans += '0 '
	print(ans)


(n, k) = map(int, input().split())
for i in range(n):
	l = [0] * n
	for j in range(n):
		if i == j:
			l[j] = k
			print(*l, sep=' ')
			break


(a, b) = map(int, input().split())
c = [1 for i in range(a)]
for j in range(a):
	if c[j] == 1:
		c[j] = b - (a - 1)
	print(*c, sep=' ')
	c = [1 for i in range(a)]


(n, k) = map(int, input().split())
matriz = []
for x in range(n):
	lista = []
	for y in range(n):
		lista.append('0')
	lista[x] = str(k)
	matriz.append(lista)
for i in matriz:
	resp = ' '.join(i)
	print(resp)


(n, sum) = map(int, input().split())
a = []
for i in range(n):
	for j in range(n):
		if i == j:
			a.append(sum)
		else:
			a.append(0)
	print(*a)
	a.clear()


def main():
	(a, b) = [int(v) for v in input().split()]
	d = b // a
	d2 = b % a
	data = []
	for i in range(a):
		r = []
		for j in range(a):
			if i == j:
				r.append(d2 + d)
			else:
				r.append(d)
		data.append(r)
	for d in data:
		print(' '.join([str(v) for v in d]))
main()


(n, m) = map(int, input().split())
i = 0
j = 0
for i in range(n):
	for j in range(n):
		if i == j:
			print(m)
		else:
			print(0)
		j += 1
	i += 1


(n, k) = map(int, input().split())
Mat = [[k if j == p else 0 for j in range(n)] for p in range(n)]
for q in Mat:
	print(*q)


(a, b) = list(map(int, input().split()))
l = []
for i in range(a):
	l.append([0 for i in range(a)])
for i in range(a):
	l[i][i] = b
for j in range(len(l)):
	print(*l[j])


def rotate(c, d):
	return c[d:] + c[:d]
(n, m) = map(int, input().split())
c = []
if m % n == 0:
	c = [m // n] * n
else:
	c = [m // n] * (n - 1)
	c.append(m - sum(c))
p = []
for i in range(n):
	p.append(rotate(c, i))
for i in p:
	print(*i)


(n, k) = map(int, input().split())
matrix = [[1 for i in range(n)] for j in range(n)]
temp = k - (n - 1)
for i in range(n):
	matrix[i][i] = temp
for i in matrix:
	print(*i)


(n, k) = map(int, input().split())
for row in range(n):
	for col in range(n):
		if row == col:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print()


inp = [int(x) for x in input().split()]
n = inp[0]
k = inp[1]
l = []
for i in range(n):
	l.append([])
	for j in range(n):
		if i == j:
			l[i].append(str(k))
		else:
			l[i].append('0')
	print(' '.join(l[i]))


(r, k) = list(map(int, input().split()))
for i in range(r):
	for j in range(r):
		if i == j:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print()


def prettyMatrix(n, k):
	matrix = [0] * n
	for i in range(n):
		matrix[i] = [0] * n
	val = k - n + 1
	for i in range(n):
		for j in range(n):
			if i == j:
				matrix[i][j] = val
			else:
				matrix[i][j] = 1
	return matrix
(n, k) = map(int, input().split())
matrix = prettyMatrix(n, k)
for i in range(n):
	for j in range(n):
		print(matrix[i][j], end=' ')
	print()


(n, m) = map(int, input().split())
dia = m - (n - 1)
for i in range(n):
	for j in range(n):
		if i == j:
			print(dia, end=' ')
		else:
			print(1, end=' ')
	print()


(n, k) = map(int, input().split())
diagonal_value = str(k - n + 1)
solution = [' '.join([diagonal_value if column == row else '1' for column in range(1, n + 1)]) for row in range(1, n + 1)]
print('\n'.join(solution))


n = []
(z, x) = [int(i) for i in input().split()]
c = x - (z - 1)
for v in range(z):
	for b in range(z):
		if v == b:
			n.append(c)
		else:
			n.append(1)
	print(*n)
	n = []


a = list(input().split(' '))
(n, k) = (int(a[0]), int(a[1]))
for i in range(n):
	res = []
	for j in range(n):
		if i == j:
			print(k, end=' ')
		else:
			print(0, end=' ')
	print('\n', end='')


(n, b) = map(int, input().split())
M = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
	for j in range(n):
		if i == j:
			M[i][j] = b
for x in M:
	print(*x)


(n, k) = map(int, input().split())
row = [k // n] * n
diff = k - sum(row)
for x in range(0, diff):
	row[x] += 1
for y in range(0, n):
	print(*row)
	row.insert(0, row.pop())


(n, k) = map(int, input().split())

def create_sq_matrix(size):
	matrix = []
	a = []
	for i in range(0, size):
		for j in range(0, size):
			a.append(0)
		matrix.append(a)
		a = []
	return matrix
a = create_sq_matrix(n)
for i in range(0, len(a)):
	for j in range(0, len(a)):
		if i == j:
			a[i][j] = k
for i in range(0, len(a)):
	for j in range(0, len(a)):
		print(a[i][j], end=' ')
	print()


X = list(map(int, input().split()))
for i in range(X[0]):
	n = list()
	for j in range(X[0]):
		n.append('0' if j != i else X[1])
	print(*n, sep=' ')


vector = input()
vector = list(map(int, vector.split(' ')))
string = [str(0) for x in range(vector[0])]
for i in range(vector[0]):
	string[i] = str(vector[1])
	print(' '.join(string))
	string[i] = str(0)


(a, b) = map(int, input().split())
f = []
for x in range(a):
	for y in range(a):
		if x == y:
			f.append(b)
		else:
			f.append(0)
	print(*f)
	f = []


import math
import collections
(n, k) = list(map(int, input().split()))
if k % n == 0:
	i = str(k // n) + ' '
	for _ in range(n):
		print(i * n)
else:
	i2 = str(math.ceil(k / n))
	i1 = str(math.ceil(k / n) - 1)
	i2_len = k % n
	i1_len = n - i2_len
	l = collections.deque([i1] * i1_len + [i2] * i2_len)
	for i in range(n):
		print(' '.join(l))
		l.rotate(1)


data = input().split()
(N, K) = (int(data[0]), int(data[1]))
table = []
col = 0
while col < N:
	tmp = [0] * N
	tmp[col] = K
	table.append(tmp)
	col += 1
for row in table:
	print(' '.join(map(str, row)))


(n, k) = map(int, input().split())
lst = []
ans = []
for i in range(n):
	if i + 1 != n:
		lst.append('0')
	else:
		lst.append(str(k))
ans.append(' '.join(lst))
for i in range(1, n):
	x = lst.pop(0)
	lst.append(x)
	ans.append(' '.join(lst))
print('\n'.join(ans))


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
(n, m) = In()
for i in range(n):
	arr = [0] * i + [m] + [0] * (n - 1 - i)
	for j in range(n):
		print(arr[j], end=' ')
	print()


(n, k) = map(int, input().split())
r = k // n
d = k - r * (n - 1)
for i in range(n):
	row = []
	for j in range(n):
		ans = int(j == i) * d + int(j != i) * r
		row.append(str(ans))
	print(' '.join(row))


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

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

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, k) = mp()
	for i in range(n):
		for j in range(n):
			if i == j:
				print(k, end=' ')
			else:
				print(0, end=' ')
		print()
for _ in range(1):
	solve()


inp = list(map(int, input().split(' ')))
store = []
for i in range(inp[0]):
	store.append(['0'] * inp[0])
for i in range(inp[0]):
	store[i][i] = str(inp[1])
for x in store:
	print(' '.join(x))


(n, k) = map(int, input().strip().split())
res = [0 for a in range(0, n - 1)]
res.append(k)
for i in range(0, n):
	print(*res)
	res = res[1:] + [res[0]]


(n, k) = [int(x) for x in input().split()]
arr = []
for i in range(n):
	tmp = []
	for j in range(n):
		if j == i:
			tmp.append(k)
		else:
			tmp.append(0)
	arr.append(tmp)
for i in range(n):
	print(*arr[i])


(n, k) = map(int, input().split())
a = '0' * n
a = ' '.join(a)
a = a.split()
for i in range(n):
	a[i] = str(k)
	for j in a:
		print(j, end=' ')
	print()
	a[i] = '0'


(n, k) = input().split()
n = int(n)
k = int(k)
l = []
temp = []
for i in range(n):
	temp = []
	for j in range(n):
		if i == j:
			temp.append(k)
		else:
			temp.append(0)
	l.append(temp)
for i in range(n):
	for j in range(n):
		print(l[i][j], end=' ')
	print()


list = [int(x) for x in input().split(' ')]
for i in range(list[0]):
	arr = [list[1] if x == i else 0 for x in range(list[0])]
	print(' '.join((str(x) for x in arr)))


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
(n, k) = q()
print('\n'.join([' '.join([f'{k}' if i == j else '0' for i in range(n)]) for j in range(n)]))


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	(n, k) = map(int, input().split())
	mat = [[0 for i in range(n)] for j in range(n)]
	for i in range(n):
		for j in range(n):
			if i == j:
				mat[i][j] = k
			else:
				mat[i][j] = 0
	for r in mat:
		print(*r)
t = 1
for _ in range(t):
	main()


(n, k) = map(int, input().split())
l1 = [k // n] * n
x = k % n
for i in range(x):
	l1[i] += 1
ans = []
for i in range(n):
	ans.append(l1[i:] + l1[:i])
for item in ans:
	print(' '.join((str(x) for x in item)))


import sys
import itertools
import collections

def rs(x=''):
	return sys.stdin.readline().strip() if len(x) == 0 else input(x).strip()

def ri(x=''):
	return int(rs(x))

def rm(x=''):
	return map(str, rs(x).split())

def rl(x=''):
	return rs(x).split()

def rmi(x=''):
	return map(int, rs(x).split())

def rli(x=''):
	return [int(x) for x in rs(x).split()]

def println(val):
	sys.stdout.write(str(val) + '\n')

def solve(testCase):
	(n, k) = rmi()
	a = [[0 for _ in range(n)] for _ in range(n)]
	for (i, j) in enumerate(range(n)):
		a[i][j] = k
	for i in range(n):
		print(*a[i])
for _ in range(ri() if 0 else 1):
	solve(_ + 1)


(n, temp) = map(int, input().split())
val = 0
arr = [[val for i in range(n)] for j in range(n)]
for i in range(n):
	arr[i][i] = temp
for i in range(n):
	for j in range(n):
		print(arr[i][j], end=' ')
	print('')