#include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int countNumBit1(int mask) {
  int ret = 0;
  while (mask) {
    mask &= (mask - 1);
    ++ret;
  }
  return ret;
}
void GO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int N = 10009;
int ans[N], a[N], n;
bool blk[N];
void go(int id) {
  int mi = INT_MAX, idx = 0;
  for (int i = id; i <= n; i++) {
    if (a[i] < mi) {
      mi = a[i];
      idx = i;
    }
  }
  for (int i = idx; i >= id + 1; i--) {
    swap(a[i], a[i - 1]);
  }
  for (int i = id; i < idx; i++) {
    blk[i] = 1;
  }
}
int main() {
  GO();
  int q;
  cin >> q;
  while (q--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i <= n; i++) blk[i] = 0;
    for (int i = 1; i <= n; i++) {
      if (blk[i]) {
        continue;
      }
      go(i);
    }
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
  }
}
