#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m;
  cin >> m;
  while (m--) {
    int n;
    cin >> n;
    int t;
    int a[105] = {0};
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] == 1) {
        t = i;
      }
    }
    for (int i = t - 1; i >= 1; i--) {
      swap(a[i], a[i + 1]);
    }
    while (t < n) {
      int sum = 101;
      int minn;
      for (int i = t; i <= n; i++) {
        if (a[i] < sum) {
          sum = a[i];
          minn = i;
        }
      }
      if (t == minn) {
        t++;
        continue;
      }
      for (int i = minn - 1; i >= t; i--) {
        swap(a[i], a[i + 1]);
      }
      t = minn;
    }
    for (int i = 1; i <= n; i++) {
      cout << a[i] << ' ';
    }
    cout << endl;
  }
  return 0;
}
