#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    int i = 0;
    while (i < n - 1) {
      int menor = i;
      for (int j = i; j < n; j++) {
        if (arr[j] < arr[menor]) menor = j;
      }
      if (menor == i) {
        i++;
        continue;
      }
      int val = arr[menor];
      for (int j = menor; j > i; j--) arr[j] = arr[j - 1];
      arr[i] = val;
      i = menor;
    }
    for (int j = 0; j < n; j++) cout << arr[j] << " ";
    cout << "\n";
  }
}
