#include <bits/stdc++.h>
using namespace std;
int T, n, a[150];
pair<int, int> b[150];
int main() {
  scanf("%d", &T);
  for (; T--;) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) b[i].first = a[i], b[i].second = i;
    sort(b + 1, b + n + 1);
    int l = 0, r = 1;
    for (;;) {
      for (; b[r].second < b[l].second && r <= n;) r++;
      if (r > n) break;
      for (int i = b[r].second - 1; i >= b[l].second; i--)
        if (a[i + 1] < a[i]) swap(a[i], a[i + 1]);
      l = r++;
    }
    for (int i = 1; i <= n; i++) printf("%d ", a[i]);
    printf("\n");
  }
  return 0;
}
