#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void solve() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  ;
  int K = N - 1, pos = 0;
  while (K && pos < N) {
    int v = INT_MAX, t = INT_MAX;
    for (int i = (int)(pos + 1); i < (int)(min(pos + K + 1, N)); i++)
      if (A[pos] > A[i] && chmin(v, A[i])) t = i;
    if (t != INT_MAX) {
      for (int i = (int)(t - 1); i >= pos; i--) swap(A[i], A[i + 1]);
      K -= t - pos;
      pos += t - pos;
    } else {
      pos++;
    }
  }
  for (auto a : A) cout << a << " ";
  cout << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < (int)(t); i++) solve();
  return 0;
}
