#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <assert.h>

using namespace std;

bool com(pair<string, int> a, pair<string, int> b)
{
    return (a.first + b.first) < (b.first + a.first);
}

int main()
{
    freopen("champ.in", "r", stdin);
    freopen("champ.out", "w", stdout);
    int n;
    cin >> n;
    assert(n <= 1e4);
    vector<pair<string, int> > a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first;
        assert(a[i].first.length() <= 20);
        for (size_t j = 0; j < a[i].first.length(); j++)
            assert('a' <= a[i].first[j] && a[i].first[j] <= 'z');
        a[i].second = i + 1;
    }
    stable_sort(a.begin(), a.end(), com);
    for (int i = 0; i < n; i++)
        cout << a[i].second << "\n";
}