#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> a(n), vis(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int j = 0; j < n; j++)
      for (int i = n - 1; i > 0; i--)
        if (a[i] < a[i - 1] && vis[i] == 0) {
          vis[i] = 1;
          swap(a[i], a[i - 1]);
        }
    for (int i = 0; i < n; i++) cout << a[i] << " ";
    cout << "\n";
  }
}
