#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
int a[105];
int b[105];
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      b[a[i]] = i;
    }
    int now = 1;
    int f = 0;
    while (now < n) {
      int ff = b[now] - 1;
      for (int i = b[now] - 1; i > f; i--) {
        if (a[i] < a[i + 1]) break;
        swap(a[i], a[i + 1]);
        b[a[i]] = i;
        b[a[i + 1]] = i + 1;
      }
      f = max(f, ff);
      now++;
    }
    for (int i = 1; i <= n; i++) {
      if (i - 1) cout << " ";
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}
