#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T;
  cin >> T;
  for (int test_case = 1; test_case <= T; ++test_case) {
    int n;
    cin >> n;
    int input[n + 1];
    for (int i = 1; i <= n; ++i) cin >> input[i];
    int idx = 1;
    while (idx <= n) {
      int min_ = input[idx];
      int min_idx = idx;
      for (int i = idx; i <= n; ++i) {
        if (input[i] < min_) {
          min_ = input[i];
          min_idx = i;
        }
      }
      if (min_ == input[idx]) {
        ++idx;
        continue;
      }
      int next_idx = min_idx;
      while (min_idx != idx) {
        swap(input[min_idx], input[min_idx - 1]);
        --min_idx;
      }
      idx = next_idx;
    }
    for (int i = 1; i <= n; ++i) cout << input[i] << ' ';
    cout << '\n';
  }
}
