#include <bits/stdc++.h>
using namespace std;
int a[1000];
int FindMin(int l, int n) {
  int min = a[l], minid = l;
  for (int i = l + 1; i < n; i++) {
    if (min > a[i]) {
      min = a[i];
      minid = i;
    }
  }
  return minid;
}
void move(int id, int l) {
  int x = a[id];
  for (int i = id; i > l; i--) {
    a[i] = a[i - 1];
  }
  a[l] = x;
}
int main() {
  int m, n, min;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> n;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
    }
    for (int j = 0; j < n - 1;) {
      min = FindMin(j, n);
      move(min, j);
      if (min == j) {
        j++;
      } else {
        j = min;
      }
    }
    for (int j = 0; j < n; j++) {
      cout << a[j] << " ";
    }
    cout << endl;
  }
}
