#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e5 + 10;
int n, m, k, T;
int a[110];
void solve(int l, int r) {
  if (l >= r) return;
  int ind = l, mi = a[l];
  for (int i = l; i <= r; i++)
    if (a[i] < mi) {
      ind = i, mi = a[i];
    }
  for (int i = ind; i > l; i--) swap(a[i], a[i - 1]);
  if (ind != l)
    solve(ind, r);
  else
    solve(ind + 1, r);
}
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    solve(1, n);
    for (int i = 1; i <= n; i++) cout << a[i] << " ";
    cout << endl;
  }
}
