#include <bits/stdc++.h>
using namespace std;
int freq[1001];
int arr[1003];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int ans = n - 1;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    int mn = 1;
    int j = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (arr[i] == mn && i != j && ans > 0 && freq[i - 1] == 0 &&
          arr[i] < arr[i - 1]) {
        swap(arr[i], arr[i - 1]);
        freq[i - 1] = 1;
        ans--;
      }
      if (ans > 0 && i == 0) {
        j++;
        mn++;
        i = n;
        continue;
      }
      if (mn == n) break;
    }
    memset(freq, 0, sizeof freq);
    for (int i = 0; i < n; i++) cout << arr[i] << " ";
    cout << endl;
  }
}
