#include <bits/stdc++.h>
using namespace std;
int vis[101], a[101];
void work(int l, int r) {
  if (l == r) {
    cout << a[l] << endl;
    return;
  }
  int xiao = 9999, wei = -1;
  for (int i = l; i <= r; i++)
    if (a[i] < xiao) {
      xiao = a[i];
      wei = i;
    }
  cout << a[wei] << " ";
  for (int i = l; i < wei - 1; i++) cout << a[i] << " ";
  a[wei] = a[wei - 1];
  if (wei == l) wei++;
  work(wei, r);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    memset(vis, 0, sizeof(vis));
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    work(1, n);
  }
}
