#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n;
    vector<int> a(n);
    vector<bool> b(n);
    for (int j = 0; j < n; ++j) {
      cin >> a[j];
      b[j] = true;
    }
    b[0] = false;
    for (int l = 0; l < n; ++l) {
      int k = n, m = n + 1;
      for (int j = n - 1; j > 0; --j) {
        if (!(b[j])) continue;
        if (a[j] < m && a[j] < a[j - 1]) {
          m = a[j];
          k = j;
        }
      }
      if (k == n) break;
      int tmp = a[k];
      a[k] = a[k - 1];
      a[k - 1] = tmp;
      b[k] = false;
    }
    for (int j = 0; j < n; ++j) {
      cout << a[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
