#include <iostream>
using namespace std;
const int TEN = 10;
bool notPerfectSquare(int x) {
int div = 0;
while (div * div < x) {
++div;
}
return div * div != x;
}
int nextPerfectSquare(int& x) {
do {
++x;
} while (notPerfectSquare(x));
return x;
}
void generateMatrix(int matrix[][TEN], int n, int x) {
int firstRow = 0, firstColumn = 0;
int lastRow = n - 1, lastColumn = n - 1;
while (firstRow <= lastRow && firstColumn <= lastColumn) {
for (int i = lastRow; i >= firstRow; --i) {
matrix[i][firstColumn] = nextPerfectSquare(x);
}
for (int j = firstColumn + 1; j <= lastColumn; ++j) {
matrix[firstRow][j] = nextPerfectSquare(x);
}
for (int i = firstRow + 1; i <= lastRow && firstColumn < lastColumn; ++i) {
matrix[i][lastColumn] = nextPerfectSquare(x);
}
for (int j = lastColumn - 1; j > firstColumn && firstRow < lastRow; --j) {
matrix[lastRow][j] = nextPerfectSquare(x);
}
++firstRow;
++firstColumn;
--lastRow;
--lastColumn;
}
}
int main() {
int n, x, matrix[TEN][TEN];
cin >> n >> x;
generateMatrix(matrix, n, x);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
cout << matrix[i][j] << ' ';
}
cout << '\n';
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IFRFTiA9IDEwOwoKYm9vbCBub3RQZXJmZWN0U3F1YXJlKGludCB4KSB7CiAgICBpbnQgZGl2ID0gMDsKICAgIHdoaWxlIChkaXYgKiBkaXYgPCB4KSB7CiAgICAgICAgKytkaXY7CiAgICB9CiAgICByZXR1cm4gZGl2ICogZGl2ICE9IHg7Cn0KCmludCBuZXh0UGVyZmVjdFNxdWFyZShpbnQmIHgpIHsKICAgIGRvIHsKICAgICAgICArK3g7CiAgICB9IHdoaWxlIChub3RQZXJmZWN0U3F1YXJlKHgpKTsKICAgIHJldHVybiB4Owp9Cgp2b2lkIGdlbmVyYXRlTWF0cml4KGludCBtYXRyaXhbXVtURU5dLCB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