#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
template <class T, class U>
inline void checkmin(T &x, U y) {
  if (y < x) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
  if (y > x) x = y;
}
template <class T, class U>
inline bool ifmax(T &x, U y) {
  if (y > x) return x = y, true;
  return false;
}
template <class T, class U>
inline bool ifmin(T &x, U y) {
  if (y < x) return x = y, true;
  return false;
}
template <class T>
inline void sort(T &a) {
  sort(a.begin(), a.end());
}
template <class T>
inline void rsort(T &a) {
  sort(a.rbegin(), a.rend());
}
template <class T>
inline void reverse(T &a) {
  reverse(a.begin(), a.end());
}
template <class T, class U>
inline istream &operator>>(istream &str, pair<T, U> &p) {
  return str >> p.first >> p.second;
}
template <class T>
inline istream &operator>>(istream &str, vector<T> &a) {
  for (auto &i : a) str >> i;
  return str;
}
bool cmp(const pair<pair<string, int>, int> &a,
         const pair<pair<string, int>, int> &b) {
  if (a.first.first != b.first.first) return a.first.first < b.first.first;
  return a.first.second > b.first.second;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout << fixed << setprecision(12);
  ;
  srand(94385);
  int n;
  cin >> n;
  vector<pair<pair<string, int>, int>> a(n);
  for (int i = 0; i < n; ++i) {
    a[i].second = i;
    cin >> a[i].first;
  }
  sort(a.begin(), a.end(), cmp);
  for (auto i : a) cout << i.second + 1 << '\n';
  return 0;
}
