#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, t;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> a(n + 1, 0), vis(n + 1, 0);
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = n - 1; i > 0; i--)
      for (int j = i; j < n; j++)
        if (a[j] > a[j + 1] && vis[j] == 0) {
          swap(a[j], a[j + 1]);
          vis[j] = 1;
        }
    for (int i = 1; i <= n; i++) cout << a[i] << ' ';
    cout << '\n';
  }
  return 0;
}
