﻿#include <iostream>
using namespace std;

int main()
{
    // Ciklusok egymásban (egymásba ágyazott ciklusok)

    // 1. feladat. Írjuk ki:
    /*
        1 2 3 4 5 6
        1 2 3 4 5 6
        1 2 3 4 5 6
        1 2 3 4 5 6
        1 2 3 4 5 6

        Tehát 5 sor, minden soron term. számok 1-től 6-ig.
    */

    /*int j = 1;
    while (j <= 5) {
        int i = 1;
        while (i <= 6) {
            cout << i << " ";
            i = i + 1;
        }

        cout << endl;
        j = j+1;
    }*/


    // 2. feladat. Írjuk ki:
    /*
        1 2 3 4 5 6
        6 5 4 3 2 1
        1 2 3 4 5 6
        6 5 4 3 2 1
        ...
        ...

        Legyen n sor (n-t a felhasználó adja meg).
    */
    int n;
    cin >> n;

    int j = 1;
    while (j <= n) {
        if (j % 2 == 0) {
            int i = 6;
            while (i >= 1) {
                cout << i << " ";
                i = i - 1;
            }
        }
        else {
            int i = 1;
            while (i <= 6) {
                cout << i << " ";
                i = i + 1;
            }
        }

        cout << endl;
        j = j+1;
    }

    // HF:
    // 1. beolvasunk n-t, írjuk ki
    /*
        1
        1 2
        1 2 3
        1 2 3 4
        .....
        1 2 3 4 ... n
    */

    // 2. beolvasunk n-t, írjuk ki
    /*
        n   n-1 n-2 ... 3 2 1
        n-1 n-2 n-3 ... 2 1
        ...
        ...
        3 2 1
        2 1
        1
    */


    return 0;
}
