#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
int n, x, y, i, s, a[111], b, t, j;
map<int, int> p;
int main() {
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  cin >> t;
  for (; t; t--) {
    cin >> n;
    p.clear();
    for (i = 1; i <= n; i++) {
      cin >> a[i];
      p[a[i]] = i;
    }
    x = 1;
    y = 1;
    for (i = 1; i <= n; i++) {
      if (x >= p[i]) continue;
      y = x + 1;
      x = p[i];
      for (j = x; j >= y && a[j] < a[j - 1]; j--) swap(a[j], a[j - 1]);
    }
    for (i = 1; i <= n; i++) cout << a[i] << ' ';
    cout << "\n";
  }
  return 0;
}
