#include <bits/stdc++.h>
using namespace std;
long long a[104];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    vector<bool> used(101, 0);
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long j = 0; j < n; j++) {
      for (long long i = n - 1; i >= 0; i--) {
        if (a[i] < a[i - 1] && !used[i]) swap(a[i], a[i - 1]), used[i] = 1;
      }
    }
    for (long long i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
}
