#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, i;
  cin >> n;
  vector<long long int> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
  }
  long long int pos = 0;
  while (pos < n) {
    long long int nx = min_element(a.begin() + pos, a.end()) - a.begin();
    long long int e = a[nx];
    a.erase(a.begin() + nx);
    a.insert(a.begin() + pos, e);
    if (pos == nx)
      pos = nx + 1;
    else
      pos = nx;
  }
  for (i = 0; i < n; i++) {
    cout << a[i] + 1 << " ";
  }
  cout << endl;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
