#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int a[maxn];
void Swap(int st, int ed) {
  int t = a[ed];
  for (int i = ed; i > st; i--) {
    a[i] = a[i - 1];
  }
  a[st] = t;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int n;
    scanf("%d", &n);
    int rest = n - 1;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    int st = 1;
    while (rest && st <= n) {
      int minn = 105, minpos;
      for (int i = st; i <= n; i++) {
        if (a[i] <= minn) {
          minn = a[i];
          minpos = i;
        }
      }
      if (minpos - st <= rest) {
        Swap(st, minpos);
        rest -= (minpos - st);
        if (st == minpos) {
          st += 1;
        } else {
          st = minpos;
        }
      } else {
        Swap(st, minpos - rest);
        rest = 0;
      }
    }
    for (int i = 1; i <= n; i++) {
      printf("%d ", a[i]);
    }
    puts("");
  }
  return 0;
}
