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: import java.util.*;
  public class P1575AL {
  	public static void main(String[] args) {
          Scanner s = new Scanner(System.in);
   
          solve(s.nextInt(), s.nextInt(), s);
      }
   
   
      public static void solve(int n, int l, Scanner s) {
          String arr[][] = new String[n][2];
          for (int i = 1; i <= n; i++) {
              arr[i - 1] = new String[]{s.next(), i + ""};
          }
   
          Arrays.sort(arr, new Comparator<String[]>() {
              @Override
              public int compare(String[] a, String[] b) {
                  String s1 = a[0];
                  String s2 = b[0];
                  for (int i = 0; i < l; i++) {
                      if (s1.charAt(i) != s2.charAt(i)) return i % 2 == 0 ^ (s1.charAt(i) > s2.charAt(i)) ? -1 : 1;
                  }
                  return 0;
              }
          });
   
          StringBuilder sb = new StringBuilder();
          for (int i = 0; i < n; i++) {
              sb.append(arr[i][1]+" ");
          }
   
          System.out.println(sb);
      }
  	/*
  	public static void main(String[] args) {
  		Scanner s = new Scanner(System.in);
  		int n = Integer.parseInt(s.next()), m = Integer.parseInt(s.next());
  		HashMap<String, Integer> map = new HashMap<String, Integer>();
  		ArrayList<String> a = new ArrayList<String>();
  		for(int i = 0; i<n; i++) {
  			String x = s.next();
  			a.add(x);
  			map.put(x, i);
  		}
  		//sort
  		Collections.sort(a);
  		a = solve(a, 0, m);
  		for(int i = 0; i<n; i++) {
  			System.out.println(map.get(a.get(i)));
  		}
  		s.close();
  	}
  	public static ArrayList<String> sort(ArrayList<String> arr, int a, int b, int curr, int m) {
  		ArrayList<String> tem = new ArrayList<String>();
  		ArrayList<Character> temp = new ArrayList<Character>();
  		ArrayList<String> ans = new ArrayList<String>();
  		for(int i = a; i<b; i++) {
  			tem.add(arr.get(i));
  			temp.add(arr.get(i).charAt(curr+1));
  		}
  		Collections.sort(temp);
  		if(curr%2==1) { //descending
  			Collections.reverse(temp);
  		}
  		//assign
  		for(int i = temp.size()-1; i>=0; i--) {
  			int index = 0;
  			loop: for(int j = 0; j<tem.size(); j++) {
  				if(tem.get(j).charAt(curr)==temp.get(0)) {
  					index = j;
  					break;
  				}
  			}
  			ans.add(tem.get(index));
  			tem.remove(index);
  			temp.remove(0);
  		}
  		return ans;
  	}
  	public static ArrayList<String> solve(ArrayList<String> arr, int curr, int m) {
  		//exit case
  		if(curr==m) {
  			return arr;
  		}
  		//generate partitions
  		char cu = arr.get(0).charAt(curr);
  		int beg = 0, end = 0;
  		for(int i = 0; i<arr.size(); i++) {
  			if(arr.get(i).charAt(curr)==cu)
  				end++;
  			else {
  				ArrayList<String> temp = sort(arr, beg, end, curr, m);
  				for(int j = end; j>=beg; j--) {
  					arr.remove(i);
  				}
  				for(int j = temp.size()-1; j>=0; j--) {
  					arr.add(0, temp.get(i));
  				}
  				if(end==arr.size()-1) {
  					continue;
  				} else {
  					beg = end+1;
  					end = beg;
  				}
  			}	
  		}
  		return solve(arr, curr+1, m); //recurse
  	}*/
  }
  