#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (long long int i = 0; i < n;) {
      long long int mini = i, flag = 1;
      for (long long int j = i; j < n; j++) {
        if (a[mini] > a[j]) mini = j;
      }
      for (long long int j = mini - 1; j >= i; j--) {
        flag = 0;
        swap(a[j], a[j + 1]);
      }
      i = mini + flag;
    }
    for (long long int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
