#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long cd(long long a, long long b) {
  if (a == 0)
    return b;
  else if (b == 0)
    return a;
  else
    return cd(b, a % b);
}
long long f(long long val) {
  long long min = -1, max = v.size(), guess = (min + max) / 2;
  while (min + 1 != max) {
    if (val >= v[guess])
      min = guess;
    else
      max = guess;
    guess = (min + max) / 2;
  }
  return min;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  deque<int> d;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    char str[n + 3][m + 2];
    v.clear();
    for (int i = 0; i < n; i++) cin >> str[i];
    long long cou = 1, tem;
    for (int i = 0; i < n; i++) {
      cou = 1;
      tem = 0;
      for (int j = m - 1; j >= 0; j--) {
        if (str[i][j] == 49) tem += cou;
        cou = cou * 2;
      }
      v.push_back(tem);
    }
    sort(v.begin(), v.end());
    long long m1 = 0, vv = pow(2, m) - 1 - n, m2 = pow(2, m);
    vv = vv / 2 + 1;
    long long guess = (m1 + m2) / 2;
    while (m1 + 1 != m2) {
      if (vv >= guess + 1 - (f(guess) + 1)) {
        if (vv == guess - f(guess) && vv != guess + 1 && f(guess) != -1 &&
            guess == v[f(guess)])
          m2 = guess;
        else
          m1 = guess;
      } else
        m2 = guess;
      guess = (m1 + m2) / 2;
    }
    d.clear();
    {
      for (int j = 0; j < m; j++) {
        d.push_back(m1 % 2);
        m1 = m1 / 2;
      }
      while (d.size()) {
        cout << d.back();
        d.pop_back();
      }
      cout << endl;
    }
  }
  return 0;
}
