#include <bits/stdc++.h>
using namespace std;
namespace Rahul {
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int pow(long long int x, long long int n, long long int mod) {
  if (n == 0) return 1;
  long long int res = pow(x, n / 2, mod);
  res = (res * res) % mod;
  if (n % 2) res = (res * x) % mod;
  return res;
}
long long int _gcd(long long int a, long long int b) {
  if (a == 0)
    return b;
  else
    return _gcd(b % a, a);
}
};  // namespace Rahul
using namespace Rahul;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    int ind[n + 1];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      ind[a[i]] = i;
    }
    bool flag[n + 1];
    memset(flag, true, sizeof(flag));
    bool temp = true;
    while (temp) {
      temp = false;
      for (int i = n - 1; i > 0; i--) {
        if (flag[i] && a[i] < a[i - 1]) {
          temp = true;
          flag[i] = false;
          int cas = a[i];
          a[i] = a[i - 1];
          a[i - 1] = cas;
        }
      }
    }
    for (int i = 0; i < n; i++) cout << a[i] << " ";
    cout << endl;
  }
}
