#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <string>
using namespace std;

int n, i, j;

struct bits
{
    int bts[12];
    bool visited;
};

vector<bits> poss;

bool comp(bits A, bits B)
{
    int c = 0;
    for (int l = 0; l < n; l++)
    {
        if (A.bts[l] != B.bts[l])
            c++;
    }
    if (c == 1)
        return true;
    return false;
}


int main()
{
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);

    /*cin >> n;
    for (i = 0; i < (1 << n); i++)
    {
        bits x;
        for (j = n-1; j >=0; j--)
        {
            if ((i & (1 << j)) == (1 << j))
            {
                //cout << 1;
                x.bts[j] = 1;
            }
            else
                x.bts[j] = 0;
        }
        x.visited = false;
        poss.push_back(x);
    }
    int k;
    int cnt2 = 0;
    sort(poss.begin(), poss.end(), comp);
    /*for (i = 0; i < poss.size(); i++)
    {
        if (poss[i].visited)
            continue;
        for (k = 0; k < n; k++)
        {
            cout << poss[i].bts[k];
        }
        cnt2++;
        cout << "\n";
        poss[i].visited = true;
        for (j = 0; j < poss.size(); j++)
        {
            if (poss[j].visited)
                continue;
            int cnt = 0;
            for (k = 0; k < n; k++)
            {
                if (poss[i].bts[k] != poss[j].bts[k])
                {
                    cnt++;
                }
            }
            if (cnt == 1)
            {
                i = j - 1;
                break;
            }
        }
    }
    
    for (i = 0; i < poss.size(); i++)
    {
        for (k = 0; k < n; k++)
        {
            cout << poss[i].bts[k];
        }
        cout << "\n";
    }
    return 0;*/
    int mat[16][16] = {
        { 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2 },
        { 3, 4, 2, 1, 2, 3, 4, 1, 3, 4, 2, 1, 2, 3, 4, 1 },
        { 2, 1, 4, 3, 4, 1, 2, 3, 2, 1, 4, 3, 4, 1, 2, 3 },
        { 4, 3, 1, 2, 3, 4, 1, 4, 4, 3, 1, 2, 3, 4, 1, 4 },
        { 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2 },
        { 3, 4, 2, 1, 2, 3, 4, 1, 3, 4, 2, 1, 2, 3, 4, 1 },
        { 2, 1, 4, 3, 4, 1, 2, 3, 2, 1, 4, 3, 4, 1, 2, 3 },
        { 4, 3, 1, 2, 3, 4, 1, 4, 4, 3, 1, 2, 3, 4, 1, 4 },
        { 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2 },
        { 3, 4, 2, 1, 2, 3, 4, 1, 3, 4, 2, 1, 2, 3, 4, 1 },
        { 2, 1, 4, 3, 4, 1, 2, 3, 2, 1, 4, 3, 4, 1, 2, 3 },
        { 4, 3, 1, 2, 3, 4, 1, 4, 4, 3, 1, 2, 3, 4, 1, 4 },
        { 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2 },
        { 3, 4, 2, 1, 2, 3, 4, 1, 3, 4, 2, 1, 2, 3, 4, 1 },
        { 2, 1, 4, 3, 4, 1, 2, 3, 2, 1, 4, 3, 4, 1, 2, 3 },
        { 4, 3, 1, 2, 3, 4, 1, 4, 4, 3, 1, 2, 3, 4, 1, 4 },
    };
    for (i = 0; i < 16; i++)
    {
        for (j = 0; j < 16; j++)
        {
            cout << mat[i][j] << " ";
        }
        cout << "\n";
    }
}