#include <bits/stdc++.h>
using namespace std;
inline void io() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cout << fixed << setprecision(8);
  long long int t = 0, n, m, c, b, s = 0;
  cin >> t;
  for (int k = 0; k < t; k++) {
    cin >> n;
    long long int a[n];
    m = INT_MAX, s = -1;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<long long int> v;
    for (int i = n - 1; i > 0; i--) {
      if (a[i] < a[i - 1]) {
        swap(a[i], a[i - 1]);
      } else {
        v.push_back(i - 1);
      }
    }
    s = 1;
    while (s != 0 && v.size() > 0) {
      s = 0;
      for (int i = v.size() - 1; i >= 0; i--) {
        if (v[i] != -1 && a[v[i]] > a[v[i] + 1]) {
          swap(a[v[i]], a[v[i] + 1]);
          v[i] = -1;
          s++;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
