#include <bits/stdc++.h>
using namespace std;
int const maxn = 111, oo = 1e9;
int t, n, bd, kt, dem, mi;
int a[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> t;
  for (int t1 = 1; t1 <= t; t1++) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    bd = 1, dem = 0;
    while (bd != n) {
      mi = oo;
      for (int i = bd; i <= n; i++)
        if (a[i] < mi) mi = a[i], kt = i, dem++;
      for (int i = kt; i >= bd + 1; i--) a[i] = a[i - 1];
      a[bd] = mi;
      dem--;
      if (bd == kt)
        bd = kt + 1;
      else
        bd = kt;
    }
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << "\n";
  }
}
