#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    static int a[101], vis[101];
    cin >> n;
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (a[j] == i) {
          for (int k = j - 1; k >= 1; --k)
            if (!vis[k] && a[k] > a[k + 1]) {
              vis[k] = 1;
              swap(a[k], a[k + 1]);
            }
          break;
        }
    for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
    cout << '\n';
  }
}
