#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 7;
int arr[maxn];
int vis[maxn];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(vis, 0, sizeof(vis));
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &arr[i]);
    }
    int sum = n - 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (arr[j] == i) {
          while (j != i && sum && !vis[j] && arr[j] < arr[j - 1]) {
            int t = arr[j];
            arr[j] = arr[j - 1];
            arr[j - 1] = t;
            vis[j] = 1;
            j--;
            sum--;
          }
          break;
        }
      }
      if (!sum) break;
    }
    for (int i = 1; i <= n; i++) {
      printf("%d%c", arr[i], i == n ? '\n' : ' ');
    }
  }
}
