#include <bits/stdc++.h>
using namespace std;
void setup() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void solve();
int main() {
  setup();
  int q;
  cin >> q;
  while (q--) solve();
  return 0;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> used(n, false);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int e = 1; e < n + 1; e++) {
    for (int i = 0; i < n; i++) {
      if (a[i] == e) {
        for (int j = i - 1; j >= 0 && !used[j]; j--) {
          if (a[j] > a[j + 1]) {
            int t = a[j + 1];
            a[j + 1] = a[j];
            a[j] = t;
            used[j] = true;
          } else
            break;
        }
        break;
      }
    }
  }
  copy(a.begin(), a.end(), ostream_iterator<int>(cout, " "));
  cout << endl;
  ;
}
