#include <bits/stdc++.h>
using namespace std;
int t, n, now;
int arr[100 + 5];
int pos[100 + 5];
signed main() {
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n;
    now = 1;
    for (int j = 1; j <= n; j++) {
      cin >> arr[j], pos[arr[j]] = j;
    }
    for (int j = 1; j <= n; j++) {
      if (pos[j] > now) {
        int tmp = pos[j];
        for (int k = pos[j] - 1; k >= now; k--) {
          pos[arr[k]]++, pos[arr[k + 1]]--;
          swap(arr[k], arr[k + 1]);
        }
        now = tmp;
      } else if (pos[j] == now)
        now++;
    }
    for (int j = 1; j <= n; j++) cout << arr[j] << " \n"[j == n];
  }
}
