#include <bits/stdc++.h>
using namespace std;
void bubbleup(vector<short> &v, int i, int j) {
  short el = v[i];
  v.erase(v.begin() + i);
  v.insert(v.begin() + j, el);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  short q;
  cin >> q;
  short n, p, nxt, tmp;
  vector<short> v;
  while (q--) {
    v.clear();
    cin >> n;
    while (n--) {
      cin >> tmp;
      v.push_back(tmp);
    }
    n = v.size();
    p = 0;
    while (p < n) {
      nxt = min_element(v.begin() + p, v.end()) - v.begin();
      bubbleup(v, nxt, p);
      if (p == nxt)
        p = nxt + 1;
      else
        p = nxt;
    }
    for (int i = 0; i < n; i++) cout << v[i] << " ";
    cout << '\n';
  }
  return 0;
}
