#include <bits/stdc++.h>
using namespace std;
int vis[110];
int main() {
  int n, m, k = 0, l, t = 0;
  int i, j, flag = 0, T, flag1 = 0;
  int v;
  int c;
  int ans = 0;
  int a[110];
  int p;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    memset(vis, 0, sizeof(vis));
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    for (i = 1; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (a[j] == i) {
          break;
        }
      }
      while (j != 0 && a[j] < a[j - 1] && vis[j - 1] == 0) {
        t = a[j];
        a[j] = a[j - 1];
        a[j - 1] = t;
        vis[j - 1] = 1;
        j--;
      }
    }
    for (i = 0; i < n; i++) printf("%d%c", a[i], (i == n - 1) ? '\n' : ' ');
  }
}
