#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, t = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * t;
}
bool compare(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second - a.first < b.second - b.first;
}
void sieve(int N) {
  bool isPrime[1000000];
  for (int i = 0; i <= N; ++i) {
    isPrime[i] = true;
  }
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i * i <= N; ++i) {
    if (isPrime[i] == true) {
      for (int j = i * i; j <= N; j += i) isPrime[j] = false;
    }
  }
}
long long n, t, a[1000000], visited[1000000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    memset(visited, 0, 1000);
    long long flag = 1;
    while (flag) {
      flag = 0;
      for (int i = n - 1; i > 0; i--) {
        if (a[i - 1] > a[i] and !visited[i - 1]) {
          swap(a[i - 1], a[i]);
          visited[i - 1] = 1;
          flag = 1;
        }
      }
    }
    for (int i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
}
