#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e17;
const long double pi = 3.1415926535897932;
const string endstr = "\n";
template <typename T>
T gcd(T a, T b) {
  return (a == 0) ? b : gcd(b % a, a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
bool p_comp_fs(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first < p2.first;
};
bool p_comp_fg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first > p2.first;
};
bool p_comp_ss(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second < p2.second;
};
bool p_comp_sg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second > p2.second;
};
template <typename T>
vector<T> uniquen(vector<T> vec) {
  sort((vec).begin(), (vec).end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
inline long long popcnt(long long x) {
  return __builtin_popcountll((unsigned long long)x);
};
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
bool bit(long long st, long long b) { return ((st >> b) & 1) == 1; }
void solve() {
  long long N, M;
  cin >> N >> M;
  vector<long long> X(N);
  for (long long i = 0; i < N; i++) cin >> X[i];
  vector<vector<long long> > S(N, vector<long long>(M, 0));
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < M; j++) {
      char c;
      cin >> c;
      if (c == '1') S[i][j] = 1;
    }
  long long ans_v = -LINF;
  vector<long long> ans;
  for (long long st = 0; st < (1ll << N); st++) {
    vector<pair<long long, long long> > cnt;
    for (long long j = 0; j < M; j++) {
      long long c = 0;
      for (long long i = 0; i < N; i++) {
        if (bit(st, i))
          c -= S[i][j];
        else
          c += S[i][j];
      }
      cnt.push_back({c, j});
    }
    sort((cnt).begin(), (cnt).end());
    vector<long long> vals(M);
    for (long long j = 0; j < M; j++) {
      vals[cnt[j].second] = j + 1;
    }
    vector<long long> R(N);
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < M; j++) {
        R[i] += S[i][j] * vals[j];
      }
    }
    bool ok = true;
    long long ans_c = 0;
    for (long long i = 0; i < N; i++) {
      if (bit(st, i)) {
        ok = ok & (X[i] >= R[i]);
      } else {
        ok = ok & (X[i] <= R[i]);
      }
      ans_c += abs(X[i] - R[i]);
    }
    if (!ok) continue;
    if (chmax(ans_v, ans_c)) {
      ans = vals;
    }
  }
  for (long long v : ans) cout << v << " ";
  cout << endstr;
}
int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long T;
  cin >> T;
  for (long long _ = 0; _ < T; _++) {
    solve();
  }
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e17;
const long double pi = 3.1415926535897932;
const string endstr = "\n";
template <typename T>
T gcd(T a, T b) {
  return (a == 0) ? b : gcd(b % a, a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
bool p_comp_fs(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first < p2.first;
};
bool p_comp_fg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.first > p2.first;
};
bool p_comp_ss(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second < p2.second;
};
bool p_comp_sg(const pair<long long, long long> p1,
               const pair<long long, long long> p2) {
  return p1.second > p2.second;
};
template <typename T>
vector<T> uniquen(vector<T> vec) {
  sort((vec).begin(), (vec).end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
inline long long popcnt(long long x) {
  return __builtin_popcountll((unsigned long long)x);
};
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
bool bit(long long st, long long b) { return ((st >> b) & 1) == 1; }
void solve() {
  long long N, M;
  cin >> N >> M;
  vector<long long> X(N);
  for (long long i = 0; i < N; i++) cin >> X[i];
  vector<vector<long long> > S(N, vector<long long>(M, 0));
  for (long long i = 0; i < N; i++)
    for (long long j = 0; j < M; j++) {
      char c;
      cin >> c;
      if (c == '1') S[i][j] = 1;
    }
  long long ans_v = -LINF;
  vector<long long> ans;
  for (long long st = 0; st < (1ll << N); st++) {
    vector<pair<long long, long long> > cnt;
    for (long long j = 0; j < M; j++) {
      long long c = 0;
      for (long long i = 0; i < N; i++) {
        if (bit(st, i))
          c -= S[i][j];
        else
          c += S[i][j];
      }
      cnt.push_back({c, j});
    }
    sort((cnt).begin(), (cnt).end());
    vector<long long> vals(M);
    for (long long j = 0; j < M; j++) {
      vals[cnt[j].second] = j + 1;
    }
    vector<long long> R(N);
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < M; j++) {
        R[i] += S[i][j] * vals[j];
      }
    }
    bool ok = true;
    long long ans_c = 0;
    for (long long i = 0; i < N; i++) {
      if (bit(st, i)) {
        ok = ok & (X[i] >= R[i]);
      } else {
        ok = ok & (X[i] <= R[i]);
      }
      ans_c += abs(X[i] - R[i]);
    }
    if (!ok) continue;
    if (chmax(ans_v, ans_c)) {
      ans = vals;
    }
  }
  for (long long v : ans) cout << v << " ";
  cout << endstr;
}
int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long T;
  cin >> T;
  for (long long _ = 0; _ < T; _++) {
    solve();
  }
  return 0;
}

```