#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
      cin >> p[i];
    }
    vector<pair<int, int>> ps(n);
    for (int i = 0; i < n; i++) {
      ps[i] = {p[i], i};
    }
    sort(ps.begin(), ps.end());
    vector<int> color(n);
    for (int i = 0; i < n; i++) {
      auto [_, index] = ps[i];
      if (i == index) {
        continue;
      }
      for (int j = index - 1; j > -1; j--) {
        if (color[j] == 0 and p[j] > p[j + 1]) {
          swap(p[j], p[j + 1]);
          color[j] = 1;
        }
      }
    }
    for (auto pi : p) {
      cout << pi << " ";
    }
    cout << endl;
  }
  return 0;
}
