description: Andi and Budi were given an assignment to tidy up their bookshelf of n books. Each book is represented by the book title — a string s_i numbered from 1 to n, each with length m. Andi really wants to sort the book lexicographically ascending, while Budi wants to sort it lexicographically descending.
  
  Settling their fight, they decided to combine their idea and sort it asc-desc-endingly, where the odd-indexed characters will be compared ascendingly, and the even-indexed characters will be compared descendingly.
  
  A string a occurs before a string b in asc-desc-ending order if and only if in the first position where a and b differ, the following holds:
  
    * if it is an odd position, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b; 
    * if it is an even position, the string a has a letter that appears later in the alphabet than the corresponding letter in b. 
  
  Input
  
  The first line contains two integers n and m (1 ≤ n ⋅ m ≤ 10^6).
  
  The i-th of the next n lines contains a string s_i consisting of m uppercase Latin letters — the book title. The strings are pairwise distinct.
  
  Output
  
  Output n integers — the indices of the strings after they are sorted asc-desc-endingly.
  
  Example
  
  Input
  
  
  5 2
  AA
  AB
  BB
  BA
  AZ
  
  
  Output
  
  
  5 2 1 3 4
  
  Note
  
  The following illustrates the first example.
  
  <image>
solution: #include <bits/stdc++.h>
  using namespace std;
  template <typename T>
  void read(T &x) {
    cin >> x;
  }
  template <typename T, typename T0>
  void read(T &x, T0 &y) {
    cin >> x >> y;
  }
  template <typename T, typename T0, typename T1>
  void read(T &x, T0 &y, T1 &z) {
    cin >> x >> y >> z;
  }
  template <typename T, typename T0, typename T1, typename T2>
  void read(T &x, T0 &y, T1 &z, T2 &w) {
    cin >> x >> y >> z >> w;
  }
  template <typename T, typename T0>
  void read(pair<T, T0> &p) {
    cin >> p.first >> p.second;
  }
  template <typename T>
  void read(vector<T> &oneD, long long int n) {
    for (long long int(i) = 0; (i) < (n); ++(i)) {
      long long int x;
      read(x);
      oneD.push_back(x);
    }
  }
  template <typename T>
  void read(T oneD[], long long int n) {
    for (long long int i = 0; i < n; i++) {
      read(oneD[i]);
    }
  }
  template <typename T>
  void write(T &x) {
    cout << x << " ";
  }
  template <typename T>
  void wrtline(T &x) {
    cout << x << "\n";
  }
  template <typename T, typename T0>
  void write(T &x, T0 &y) {
    cout << x << " " << y << "\n";
  }
  template <typename T, typename T0, typename T1>
  void write(T &x, T0 &y, T1 &z) {
    cout << x << " " << y << " " << z << "\n";
  }
  template <typename T, typename T0, typename T1, typename T2>
  void write(T &x, T0 &y, T1 &z, T2 &w) {
    cout << x << " " << y << " " << z << " " << w << "\n";
  }
  template <typename T, typename T0>
  void write(pair<T, T0> &p) {
    write(p.first);
    write(p.second);
    cout << "\n";
  }
  template <typename T>
  void write(vector<T> &oneD, long long int n) {
    for (long long int i = 0; i < n; i++) {
      cout << oneD[i] << " ";
    }
    cout << "\n";
  }
  template <typename T>
  void write(T oneD[], int &n) {
    for (long long int i = 0; i < n; i++) {
      write(oneD[i]);
    }
    cout << "\n";
  }
  template <typename T, typename T0>
  void write(map<T, T0> &mpp) {
    for (auto it : mpp) {
      write(it.first);
      cout << ": ";
      write(it.second);
      cout << "\n";
    }
    cout << "\n";
  }
  template <typename T>
  void write(vector<vector<T>> &rc, T &n, T &m) {
    for (long long int(i) = 0; (i) < (n); ++(i)) {
      for (long long int(j) = 0; (j) < (m); ++(j)) {
        cout << rc[i][j] << " ";
      }
      cout << "\n";
    }
  }
  template <typename T>
  void _print(T &t) {
    cerr << t;
  }
  template <class T, class V>
  void _print(pair<T, V> &p);
  template <class T>
  void _print(vector<T> &v);
  template <class T>
  void _print(set<T> &v);
  template <class T, class V>
  void _print(map<T, V> &v);
  template <class T>
  void _print(multiset<T> &v);
  template <class T, class V>
  void _print(pair<T, V> &p) {
    cerr << "{";
    _print(p.first);
    cerr << ",";
    _print(p.second);
    cerr << "}";
  }
  template <class T>
  void _print(vector<T> &v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(set<T> &v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T>
  void _print(multiset<T> &v) {
    cerr << "[ ";
    for (T i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  template <class T, class V>
  void _print(map<T, V> &v) {
    cerr << "[ ";
    for (auto i : v) {
      _print(i);
      cerr << " ";
    }
    cerr << "]";
  }
  void solve() {
    long long int n, m;
    read(n, m);
    vector<pair<string, long long int>> s;
    for (long long int(i) = 0; (i) < (n); ++(i)) {
      string t;
      read(t);
      s.push_back({t, i + 1});
    }
    string alphabets = "";
    for (long long int(i) = 0; (i) < (26); ++(i)) alphabets += 'A' + i;
    reverse((alphabets).begin(), (alphabets).end());
    for (long long int i = 1; i < m; i += 2) {
      for (long long int(j) = 0; (j) < (n); ++(j)) {
        s[j].first[i] = alphabets[s[j].first[i] - 'A'];
      }
    }
    sort((s).begin(), (s).end());
    for (long long int(i) = 0; (i) < (n); ++(i)) cout << s[i].second << " ";
    cout << "\n";
  }
  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
  }
  