#include <bits/stdc++.h>
using namespace std;
int num[1001];
int n;
int pos_find(int temp) {
  for (int i = 1; i <= n; i++) {
    if (num[i] == temp) return i;
  }
}
void solve() {
  int t;
  cin >> t;
  while (t--) {
    int pos;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> num[i];
      if (num[i] == 1) {
        pos = i;
      }
    }
    int cnt = 0, temp = 1, line = 2;
    while (cnt != (n - 1) && temp != n) {
      pos = pos_find(temp);
      if (pos < line) {
        temp++;
        continue;
      }
      for (int i = pos; i >= line; i--) {
        if (num[i] < num[i - 1]) {
          swap(num[i], num[i - 1]);
          cnt++;
        }
      }
      line = pos + 1;
      temp++;
    }
    for (int k = 1; k <= n; k++) {
      cout << num[k];
      if (k != n) cout << " ";
    }
    cout << endl;
  }
}
int main() {
  solve();
  return 0;
}
