#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>

using namespace std;

int dr[4] = {0, -1, 0, 1};
int dc[4] = {1, 0, -1, 0};

int main() {
    ifstream fin("DATA4.txt");
    ofstream fout("OUT4.txt");

    int m[5][5];

    for (int cc = 0; cc < 5; cc++) {
        int maxNum;
        fin >> maxNum;

        for (int r = 0; r < 5; r++) {
            for (int c = 0; c < 5; c++) {
                m[r][c] = -1;
            }
        }

        int curNum = 1;
        int topRow = 2;
        int bottomRow = 2;
        int leftCol = 2;
        int rightCol = 2;
        int curRow = 3, curCol = 1;

        m[2][2] = 0;
        for (int i = 2; i < 7; i += 2) {
            for (int side = 0; side < 4 && curNum <= maxNum; side++) {
                for (int j = 0; j < i && curNum <= maxNum; j++) {
                    curRow += dr[side];
                    curCol += dc[side];
                    m[curRow][curCol] = curNum;
                    topRow = min(curRow, topRow);
                    bottomRow = max(curRow, bottomRow);
                    leftCol = min(curCol, leftCol);
                    rightCol = max(curCol, rightCol);
                    ++curNum;
                }
            }
            --curCol;
            ++curRow;
        }

        for (int r = topRow; r <= bottomRow; r++) {
            for (int c = leftCol; c <= rightCol; c++) {
                if (m[r][c] == -1) {
                    fout << '.';
                } else {
                    fout << m[r][c];
                }
            }
            fout << endl;
        }

    }
}

