#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    int a[110], b[110];
    cin >> n;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      b[i] = 0;
    }
    int d = n - 1;
    while (d) {
      int flag = 0;
      for (int i = n; i > 1; i--) {
        if (a[i] < a[i - 1] && b[i - 1] == 0) {
          int t = a[i - 1];
          a[i - 1] = a[i];
          a[i] = t;
          d--;
          b[i - 1] = 1;
          flag = 1;
          if (d == 0) break;
        }
      }
      if (!flag || !d) break;
    }
    for (int i = 1; i < n; i++) {
      printf("%d ", a[i]);
    }
    printf("%d\n", a[n]);
  }
  return 0;
}
