#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    long long i;
    for (i = 0; i < n; i++) cin >> a[i];
    long long index = -1;
    long long aa = 0, b = n;
    while (aa < b) {
      long long min = LLONG_MAX;
      for (i = aa; i < b; i++) {
        if (a[i] < min) {
          min = a[i];
          index = i;
        }
      }
      for (i = index; i > aa; i--) {
        swap(a[i], a[i - 1]);
      }
      if (aa == index)
        aa++;
      else
        aa = index;
      b = n;
    }
    for (i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
}
