#include <iostream>
#include <ctime>

using namespace std;

int main()
{
	srand(time(NULL));

    bool game;
    int arr[4][4];

    for (int i = 0; i < 4; i++)
    {

        for (int j = 0; j < 4;)
        {
            game = true;
            arr[i][j] = rand() % 16;
            for (int r = 0; r < 4; r++)
				for (int c = 0; c < 4; c++)
				{
					if (r == i && c == j)
					{
						r = c = 4;
						continue;
					}
					if (arr[r][c] == arr[i][j])
					{
						game = false;
						r = c = 4;
					}
				}
            if (game == true)
            {
                j++;
            }
        }
    }

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
			cout << arr[i][j] << " ";
		cout << "\n";
	}
}