#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, mod = 1e9 + 7;
int a[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int cur = 0;
    for (; cur < n; cur++) {
      int mn = mod, pos = -1;
      for (int i = cur; i < n; i++) {
        if (a[i] < mn) mn = a[i], pos = i;
      }
      if (pos == cur) continue;
      for (int i = pos; i > cur; i--) swap(a[i], a[i - 1]);
      cur = pos - 1;
    }
    for (int i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
  return 0;
}
