#include <bits/stdc++.h>
using namespace std;
int solve() {
  long long int n;
  cin >> n;
  vector<long long int> input(n), operationleft(n, 1);
  for (auto &i : input) cin >> i;
  operationleft[n - 1] = 0;
  long long int maxmoves = n - 1;
  while (maxmoves--) {
    for (int i = n - 2; i >= 0; i--) {
      if (input[i] > input[i + 1] && operationleft[i] > 0) {
        swap(input[i], input[i + 1]);
        operationleft[i] = 0;
        break;
      }
    }
  }
  for (auto i : input) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}
int main() {
  long long int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
