#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200001;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
      int mn = i;
      for (int j = i + 1; j < n; j++)
        if (a[j] < a[mn]) mn = j;
      if (mn != i) {
        int tmp = a[mn];
        for (int j = mn; j > i; j--) a[j] = a[j - 1];
        a[i] = tmp;
        i = mn - 1;
      }
    }
    for (int i = 0; i < n; i++) cout << a[i] << ' ';
    cout << '\n';
  }
}
