#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, n;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> n;
    vector<int> perms(n);
    for (int j = 0; j < n; ++j) {
      cin >> perms[j];
    }
    int pos = 0;
    while (pos < n) {
      int next = distance(perms.begin(),
                          min_element(perms.begin() + pos, perms.end()));
      int el = perms[next];
      perms.erase(perms.begin() + next);
      perms.insert(perms.begin() + pos, el);
      if (pos == next)
        pos = next + 1;
      else
        pos = next;
    }
    for (auto it : perms) cout << it << " ";
    cout << endl;
  }
  return 0;
}
