#include <bits/stdc++.h>
using namespace std;
string str[1000000];
long long x, y;
bool compare1(long long i1, long long i2) {
  long long j, k;
  for (j = 0; j < x; j++) {
    if (j % 2 == 1) {
      if (str[i1][j] > str[i2][j]) {
        return 1;
      } else if (str[i1][j] < str[i2][j]) {
        return 0;
      }
    } else {
      if (str[i1][j] > str[i2][j]) {
        return 0;
      } else if (str[i1][j] < str[i2][j]) {
        return 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, i, j, k, l, r;
  cin >> n >> m;
  long long ara[n];
  for (i = 0; i < n; i++) {
    cin >> str[i];
    ara[i] = i;
  }
  x = m;
  sort(ara, ara + n, compare1);
  for (i = 0; i < n; i++) {
    cout << ara[i] + 1;
    if (i < n - 1) {
      cout << " ";
    } else {
      cout << "\n";
    }
  }
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string str[1000000];
long long x, y;
bool compare1(long long i1, long long i2) {
  long long j, k;
  for (j = 0; j < x; j++) {
    if (j % 2 == 1) {
      if (str[i1][j] > str[i2][j]) {
        return 1;
      } else if (str[i1][j] < str[i2][j]) {
        return 0;
      }
    } else {
      if (str[i1][j] > str[i2][j]) {
        return 0;
      } else if (str[i1][j] < str[i2][j]) {
        return 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, i, j, k, l, r;
  cin >> n >> m;
  long long ara[n];
  for (i = 0; i < n; i++) {
    cin >> str[i];
    ara[i] = i;
  }
  x = m;
  sort(ara, ara + n, compare1);
  for (i = 0; i < n; i++) {
    cout << ara[i] + 1;
    if (i < n - 1) {
      cout << " ";
    } else {
      cout << "\n";
    }
  }
  return 0;
}

```