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;
  const long long MAXN = 10005;
  const long long MOD = 998244353;
  const long long INF = 1e18;
  const long double EPS = 1e-7;
  inline long long summ(long long x, long long y) {
    return (x + y) - (x + y >= MOD) * MOD;
  }
  inline long long difm(long long x, long long y) {
    return (x - y) + (x - y < 0) * MOD;
  }
  inline long long mulm(long long x, long long y) { return x * y % MOD; }
  long long bin_pow(long long a, long long n) {
    long long res = 1;
    while (n) {
      if (n % 2) {
        n--;
        res = mulm(res, a);
      } else {
        n /= 2;
        a = mulm(a, a);
      }
    }
    return res;
  }
  inline long long rev(long long n) { return bin_pow(n, MOD - 2); }
  inline long long divm(long long x, long long y) { return mulm(x, rev(y)); }
  long long fact[MAXN], fact_rev[MAXN];
  void fact_init() {
    fact[0] = fact_rev[0] = 1;
    for (long long i = 1; i < MAXN; i++) {
      fact[i] = fact[i - 1] * i % MOD;
      fact_rev[i] = rev(fact[i]);
    }
  }
  inline long long comb(long long n, long long k) {
    return fact[n] * fact_rev[k] % MOD * fact_rev[n - k] % MOD;
  }
  struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
      x += 0x9e3779b97f4a7c15;
      x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
      x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
      return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
      static const uint64_t FIXED_RANDOM =
          chrono::steady_clock::now().time_since_epoch().count();
      return splitmix64(x + FIXED_RANDOM);
    }
  };
  ostream& operator<<(ostream& stream, const pair<long long, long long>& p) {
    return stream << p.first << ' ' << p.second;
  }
  ostream& operator<<(ostream& stream, const vector<long long>& v) {
    for (long long val : v) {
      stream << val << ' ';
    }
    return stream;
  }
  signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base ::sync_with_stdio(0);
    long long t;
    cin >> t;
    while (t--) {
      long long n, m;
      cin >> n >> m;
      vector<long long> x(n);
      for (long long i = 0; i < n; i++) {
        cin >> x[i];
      }
      vector<string> s(n);
      for (long long i = 0; i < n; i++) {
        cin >> s[i];
      }
      long long ans = 0;
      vector<long long> best(m);
      iota(best.begin(), best.end(), 1);
      for (long long p = 0; p < (1 << n); p++) {
        vector<pair<long long, long long>> sum(m);
        for (long long i = 0; i < m; i++) {
          sum[i].second = i;
        }
        long long res = 0;
        for (long long i = 0; i < n; i++) {
          if (p & (1 << i)) {
            res += x[i];
          } else {
            res -= x[i];
          }
          for (long long j = 0; j < m; j++) {
            if (s[i][j] == '0') {
              continue;
            }
            if (p & (1 << i)) {
              sum[j].first--;
            } else {
              sum[j].first++;
            }
          }
        }
        sort(sum.begin(), sum.end());
        for (long long i = 0; i < m; i++) {
          res += sum[i].first * (i + 1);
        }
        if (res > ans) {
          ans = res;
          for (long long i = 0; i < m; i++) {
            best[sum[i].second] = i + 1;
          }
        }
      }
      cout << best << '\n';
    }
    return 0;
  }
  