#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9 + 7;
long long n;
long long findd(long long a[], long long x) {
  long long minn = INT_MAX;
  long long p = 0;
  for (long long i = x; i < n; i++) {
    if (a[i] < minn) {
      minn = a[i];
      p = i;
    }
  }
  return p;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long q;
  cin >> q;
  while (q--) {
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long i = 0;
    while (i < n - 1) {
      long long p = findd(a, i);
      for (long long x = p; x > i; x--) {
        swap(a[x], a[x - 1]);
      }
      if (p == i) p++;
      i = p;
    }
    for (long long i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
}
