#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, n;
  ;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      --arr[i];
    }
    int pos = 0;
    while (pos < n) {
      int next = min_element(arr.begin() + pos, arr.end()) - arr.begin();
      int el = arr[next];
      arr.erase(arr.begin() + next);
      arr.insert(arr.begin() + pos, el);
      if (pos == next)
        pos = next + 1;
      else
        pos = next;
    }
    for (int i = 0; i < (int)arr.size(); i++) {
      cout << arr[i] + 1;
      if (i != (int)arr.size() - 1) cout << " ";
    }
    cout << endl;
  }
  return 0;
}
