#include <bits/stdc++.h>
using namespace std;
const int MAX = 105;
string arr[MAX];
int n, m;
int mark[MAX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
      mark[i] = 0;
    }
    long long pos = (((1ll << m) - n) - 1ll) / 2ll;
    ++pos;
    for (int i = 0; i < m; ++i) {
      long long x = (1ll << (m - i - 1ll));
      long long a = x, b = x;
      for (int j = 0; j < n; ++j) {
        if (mark[j]) continue;
        if (arr[j][i] == '0')
          a--;
        else
          b--;
      }
      if (a >= pos) {
        cout << 0;
        for (int j = 0; j < n; ++j) {
          if (arr[j][i] == '1') mark[j] = 1;
        }
      } else {
        pos -= a;
        cout << 1;
        for (int j = 0; j < n; ++j) {
          if (arr[j][i] == '0') mark[j] = 1;
        }
      }
    }
    cout << "\n";
  }
  return 0;
}
