#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100;
const long long inf = 1e9 + 7;
const long long ll_inf = 1e17 + 100;
const double pi = 3.14159265358979323;
inline void fr() {
  freopen("conquest.in", "r", stdin);
  freopen("conquest.out", "w", stdout);
}
void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int a[200], was[200];
int ans[200];
bool rer[200];
int main() {
  int t;
  cin >> t;
  for (int tt = 1; tt <= t; ++tt) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i];
      was[a[i]] = i;
    }
    int r = 1;
    for (int i = 1; i <= n; ++i) {
      for (int j = was[i]; j > 1; --j) {
        if (a[j] < a[j - 1] && rer[j] == 0) {
          rer[j] = 1;
          swap(a[j], a[j - 1]);
        } else
          break;
      }
    }
    for (int i = 1; i <= n; ++i) {
      cout << a[i] << " ";
      ans[i] = 0;
      was[i] = 0;
      a[i] = 0;
      rer[i] = 0;
    }
    cout << endl;
  }
}
