#include <bits/stdc++.h>
using namespace std;
int arr[102];
bool used[102];
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    memset(used, 0, sizeof(used));
    used[0] = 1;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    int flag = 1;
    while (flag) {
      flag = 0;
      int mi = 0x7f7f7f7f, pos = 0;
      for (int i = 0; i < n; i++) {
        if (!used[i] && arr[i] < mi) {
          flag = 1;
          mi = arr[i];
          pos = i;
        }
      }
      for (int i = pos; !used[i]; i--) {
        used[i] = 1;
        if (arr[i] < arr[i - 1])
          swap(arr[i], arr[i - 1]);
        else
          break;
      }
    }
    for (int i = 0; i < n; i++) cout << arr[i] << ' ';
    cout << endl;
  }
  return 0;
}
