#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, bool> ma;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<bool> vis(n, false);
    int ops = n - 1;
    while (ops) {
      int ma = INT_MAX;
      int mai = INT_MAX;
      for (int i = 0; i + 1 < n; ++i) {
        if (a[i] > a[i + 1] && !vis[i]) {
          if (a[i + 1] < ma) {
            ma = a[i + 1];
            mai = i;
          }
        }
      }
      if (ma == INT_MAX)
        break;
      else {
        swap(a[mai], a[mai + 1]);
        vis[mai] = true;
        ops--;
      }
    }
    for (int i = 0; i < n; ++i) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
