#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 10;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 1];
    map<long long, long long> f, make_pair;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      make_pair[a[i]] = i;
    }
    if (n == 1) {
      cout << a[0] << endl;
      continue;
    }
    long long k = n;
    for (long long i = 1; i <= n; i++) {
      for (long long j = make_pair[i]; j >= 1; j--) {
        if (f[j - 1] == 0 && a[j] < a[j - 1]) {
          swap(a[j], a[j - 1]);
          swap(make_pair[a[j]], make_pair[a[j - 1]]);
          f[j - 1] = 1;
        }
      }
    }
    for (long long i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << endl;
  }
}
