#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int q, j, i, n, cur, tot, z, vis[1000], A[1000], k;
  cin >> q;
  for (j = 1; j <= q; j++) {
    cin >> n;
    map<long long int, long long int> mp1;
    for (i = 1; i <= n; i++) {
      cin >> A[i];
      mp1[A[i]] = i;
      vis[i] = 0;
    }
    vis[0] = 0;
    A[0] = 0;
    cur = 1;
    tot = 0;
    z = 0;
    i = mp1[cur];
    z = 0;
    while (1) {
      i = mp1[cur];
      if (cur > n - 1) break;
      if (i == cur) {
        cur++;
        continue;
      }
      if (vis[i - 1] == 0 && i >= 2) {
        if (A[i - 1] > A[i]) {
          swap(A[i - 1], A[i]);
          tot++;
          vis[i - 1] = 1;
          mp1[A[i]]++;
          mp1[A[i - 1]]--;
        } else
          cur++;
      } else if (vis[i - 1] != 0) {
        cur++;
      }
      if (tot >= n - 1) {
        break;
      }
      if (cur > n - 1) break;
    }
    for (i = 1; i <= n; i++) {
      cout << A[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
