#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<pair<int, int>> v;
    char tmp = s[0];
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == tmp) {
        cnt += 1;
      } else {
        v.push_back({cnt, (tmp - '0')});
        tmp = s[i];
        cnt = 1;
      }
    }
    v.push_back({cnt, (tmp - '0')});
    stack<pair<int, pair<int, bool>>> st;
    for (int i = 0; i < v.size(); i++) {
      if (st.empty() || v[i].second == 1)
        st.push({v[i].first, {v[i].second, false}});
      else {
        bool f = false;
        while (!st.empty() && st.top().second.first == 1) {
          st.pop();
          f = true;
        }
        if (!f) {
          st.push({v[i].first, {v[i].second, false}});
        } else {
          st.push({1, {1, true}});
        }
      }
    }
    string sss = "";
    while (!st.empty()) {
      char x = (char)('0' + st.top().second.first);
      if (st.top().second.second) {
        x = '0';
      }
      while (st.top().first > 0) {
        sss = x + sss;
        st.top().first -= 1;
      }
      st.pop();
    }
    cout << sss << '\n';
  }
}
