#include <bits/stdc++.h>
using namespace std;

#define ll long long

// i -> sqrt(n)
// i*i -> n

void factorization(int n)
{
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            cout << i << " ";
            if (i * i != n)
            {
                cout << n / i << " ";
            }
        }
    }
    cout << endl;
}

map<ll, int> mp;
void prime_factorization(ll n)
{
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            n /= i;
            mp[i]++;
        }
    }
    if (n != 1)
        mp[n]++;
}

const int sz = 1000000 + 5;
bool is_prime[sz + 5];

void sieve()
{
    for (int i = 2; i <= sz; i++)
        is_prime[i] = 1;

    for (int i = 2; i * i <= sz; i++)
    {
        if (is_prime[i])
        {
            for (int j = i * i; j <= sz; j += i)
            {
                is_prime[j] = 0;
            }
        }
    }
}

const int N = 10000007;
int spf[N + 5];

void build_spf()
{
    for (int i = 1; i < N; i++)
        spf[i] = i;

    for (int i = 2; i * i < N; i++)
    {

        if (spf[i] == i)
        {
            for (int j = i * i; j < N; j += i)
            {
                if (spf[j] == j)
                {
                    spf[j] = i;
                }
            }
        }
    }
}

void Fact_spf(int n)
{
    while (n > 1)
    {
        cout << spf[n] << " ";
        n /= spf[n];
    }
}

void PREMTU(string s)
{
    sort(s.begin(), s.end());

    do
    {
        cout << s << "\n";
    } while (next_permutation(s.begin(), s.end()));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
    build_spf();
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int s[4] = {1, 2, 3, 4};
        sort(s, s + 4);

        do
        {
            for (int i = 0; i < 4; i++)
            {
                cout << s[i] << " ";
            }
            cout << endl;
        } while (next_permutation(s, s + 4));
    }
    return 0;
}