#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    freopen("champ.in", "r", stdin);
    freopen("champ.out", "w", stdout);
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<int> b(n);
    for (int i = 0; i < n; i++)
        b[i] = i;
    vector<int> c(n);
    c[0] = 1;
    for (int i = 1; i < n; i++)
        c[i] = (i + 1) * c[i - 1];
    string ans = "";
    for (int i = 0; i < n; i++)
        ans += a[i];
    vector<int> per_ans = b;
    for (int i = 0; i < c[n - 1]; i++)
    {
        string tek = "";
        for (int j = 0; j < n; j++)
            tek += a[b[j]];
        if (ans > tek) ans = tek, per_ans = b;
        next_permutation(b.begin(), b.end());
    }
    for (int i = 0; i < n; i++)
        cout << per_ans[i] + 1 << "\n";
}