#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long n;
int min_idx(int start) {
  int pos = start;
  for (int i = start + 1; i < n; i++) {
    if (v[i] < v[pos]) {
      pos = i;
    }
  }
  return pos;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    v.clear();
    v.resize(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    int x = 0;
    int prev_ = 0;
    while (x != n - 1) {
      x = min_idx(x);
      if (prev_ == x) {
        ++x;
        ++prev_;
      }
      for (int i = x; i >= prev_ + 1; i--) {
        swap(v[i], v[i - 1]);
      }
      prev_ = x;
    }
    for (int it : v) {
      cout << it << " ";
    }
    cout << "\n";
  }
  return 0;
}
