description: Petya is a math teacher. n of his students has written a test consisting of m questions. For each student, it is known which questions he has answered correctly and which he has not.
  
  If the student answers the j-th question correctly, he gets p_j points (otherwise, he gets 0 points). Moreover, the points for the questions are distributed in such a way that the array p is a permutation of numbers from 1 to m.
  
  For the i-th student, Petya knows that he expects to get x_i points for the test. Petya wonders how unexpected the results could be. Petya believes that the surprise value of the results for students is equal to ∑_{i=1}^{n} |x_i - r_i|, where r_i is the number of points that the i-th student has got for the test.
  
  Your task is to help Petya find such a permutation p for which the surprise value of the results is maximum possible. If there are multiple answers, print any of them.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases.
  
  The first line of each test case contains two integers n and m (1 ≤ n ≤ 10; 1 ≤ m ≤ 10^4) — the number of students and the number of questions, respectively.
  
  The second line contains n integers x_1, x_2, ..., x_n (0 ≤ x_i ≤ (m(m+1))/(2)), where x_i is the number of points that the i-th student expects to get.
  
  This is followed by n lines, the i-th line contains the string s_i (|s_i| = m; s_{i, j} ∈ \{0, 1\}), where s_{i, j} is 1 if the i-th student has answered the j-th question correctly, and 0 otherwise.
  
  The sum of m for all test cases does not exceed 10^4.
  
  Output
  
  For each test case, print m integers — a permutation p for which the surprise value of the results is maximum possible. If there are multiple answers, print any of them.
  
  Example
  
  Input
  
  
  3
  4 3
  5 1 2 2
  110
  100
  101
  100
  4 4
  6 2 0 10
  1001
  0010
  0110
  0101
  3 6
  20 3 15
  010110
  000101
  111111
  
  
  Output
  
  
  3 1 2 
  2 3 4 1 
  3 1 4 5 2 6 
solution: #include <bits/stdc++.h>
  using namespace std;
  inline int read() {
    int ans = 0, f = 1;
    char c = getchar();
    while (c > '9' || c < '0') {
      if (c == '-') f = -1;
      c = getchar();
    }
    while (c >= '0' && c <= '9') {
      ans = (ans << 1) + (ans << 3) + c - '0';
      c = getchar();
    }
    return ans * f;
  }
  inline void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x / 10) write(x / 10);
    putchar((char)(x % 10) + '0');
  }
  template <typename T>
  inline T Abs(T a) {
    return a > 0 ? a : -a;
  };
  template <typename T, typename TT>
  inline T Min(T a, TT b) {
    return a < b ? a : b;
  }
  template <typename T, typename TT>
  inline T Max(T a, TT b) {
    return a < b ? b : a;
  }
  const int N = 1e4 + 5;
  int t, n, m, a[N], c[N], ans;
  char s[15][N];
  pair<int, int> b[N];
  signed main() {
    t = read();
    while (t--) {
      n = read();
      m = read();
      for (int i = 1; i <= n; ++i) a[i] = read();
      for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
      ans = -1e9;
      for (int i = 0; i < (1 << n); ++i) {
        for (int j = 1; j <= m; ++j) {
          b[j] = make_pair(0, j);
          for (int k = 1; k <= n; ++k)
            if (s[k][j] == '1') {
              if ((i >> (k - 1)) & 1)
                b[j].first++;
              else
                b[j].first--;
            }
        }
        sort(b + 1, b + 1 + m);
        int tmp = 0;
        for (int j = 1; j <= n; ++j)
          if ((i >> (j - 1)) & 1)
            tmp -= a[j];
          else
            tmp += a[j];
        for (int j = 1; j <= m; ++j) tmp += j * b[j].first;
        if (tmp > ans) {
          ans = tmp;
          for (int j = 1; j <= m; ++j) c[b[j].second] = j;
        }
      }
      for (int i = 1; i <= m; ++i) write(c[i]), putchar(' ');
      puts("");
    }
    return 0;
  }
  