#include <bits/stdc++.h>
using namespace std;
inline void printArr(vector<long long> &arr) {
  for (long long i : arr) cout << i << " ";
  cout << '\n';
}
inline void printArr(vector<long long> &arr, long long n) {
  for (long long i = 0; i < n; ++i) cout << i << " ";
  cout << '\n';
}
inline void printArr(vector<long long> &arr, long long start, long long n) {
  for (long long i = start; i < start + n; ++i) cout << i << " ";
  cout << '\n';
}
const long long M = 998244353;
vector<long long> topologicalOrder(long long V, vector<long long> adj[]) {
  vector<long long> inDegree(V, 0);
  for (long long i = 0; i < V; ++i) {
    for (long long j = 0; j < adj[i].size(); ++j) ++inDegree[adj[i][j]];
  }
  queue<long long> q;
  for (long long i = 0; i < V; ++i) {
    if (inDegree[i] == 0) q.push(i);
  }
  vector<long long> topOrder;
  while (!q.empty()) {
    long long front = q.front();
    q.pop();
    topOrder.push_back(front);
    for (long long i = 0; i < adj[front].size(); ++i) {
      --inDegree[adj[front][i]];
      if (inDegree[adj[front][i]] == 0) q.push(adj[front][i]);
    }
  }
  return topOrder;
}
long long powM(long long a, long long b, long long m) {
  long long x = 1;
  while (b > 0) {
    if (b & 1) x = (x * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return x;
}
long long mulM(long long a, long long b, long long m) {
  long long res = 0;
  a = a % m;
  while (b > 0) {
    if (b % 2 == 1) res = (res + a) % m;
    a = (a * 2) % m;
    b /= 2;
  }
  return res % m;
}
long long nCr(long long n, long long r, long long m) {
  if (n < r) return 0;
  long long res = 1, rem = 1;
  for (long long i = n - r + 1; i <= n; i++) res = (res * i) % m;
  for (long long i = 2; i <= r; i++) rem = (rem * i) % m;
  return (res * powM(rem, m - 2, m)) % m;
}
long long MInverse(long long a, long long m) {
  a = a % m;
  for (long long x = 1; x < m; ++x) {
    if ((a * x) % m == 1) return x;
  }
  return -1;
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
  if (b == 0) {
    *x = 1, *y = 0;
    return a;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b, a % b, &x1, &y1);
  *x = y1, *y = x1 - (floor(a / b) * y1);
  return gcd;
}
long long factorial(long long n) {
  if (n == 1) return 1;
  return sqrt(2 * 3.141592653589793238461 * n) *
         pow((n / 2.71828182845904523536), n);
}
vector<bool> sieve(long long n) {
  long long sqrtn = sqrt(n);
  vector<bool> is_prime(n + 1, true);
  for (long long i = 3; i <= sqrtn; i += 2) {
    if (is_prime[i]) {
      long long increment = i + i;
      for (long long j = i * i; j <= n; j += increment) is_prime[j] = false;
    }
  }
  return is_prime;
}
vector<pair<long long, long long>> primeFactors(long long n) {
  vector<pair<long long, long long>> ans;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      long long cnt = 0;
      while (n % i == 0) n /= i, cnt++;
      if (cnt) ans.push_back({i, cnt});
    }
  }
  if (n > 1) ans.push_back({n, 1});
  return ans;
}
void factors(vector<pair<long long, long long>> primeFactors,
             vector<long long> &ans, long long cur = 0, long long curRes = 1) {
  if (cur == primeFactors.size()) {
    ans.push_back(curRes);
    return;
  }
  for (long long i = 0; i <= primeFactors[cur].second; ++i) {
    factors(primeFactors, ans, cur + 1, curRes);
    curRes *= primeFactors[cur].first;
  }
}
vector<vector<long long>> matMul(vector<vector<long long>> A,
                                 vector<vector<long long>> B) {
  vector<vector<long long>> C(A.size(), vector<long long>(B[0].size()));
  for (long long i = 0; i < A.size(); ++i) {
    for (long long j = 0; j < B[0].size(); ++j) {
      C[i][j] = 0;
      for (long long k = 0; k < B.size(); ++k)
        C[i][j] = (C[i][j] + ((A[i][k] * B[k][j]) % M)) % M;
    }
  }
  return C;
}
vector<vector<long long>> matPow(vector<vector<long long>> A, long long p) {
  if (p == 1) return A;
  if (p & 1)
    return matMul(A, matPow(A, p - 1));
  else {
    vector<vector<long long>> C = matPow(A, p / 2);
    return matMul(C, C);
  }
}
vector<long long> zFunction(string s) {
  long long n = s.size(), L = 0, R = 0;
  vector<long long> z(n);
  for (long long i = 1; i < n; ++i) {
    if (i > R) {
      L = R = i;
      while (R < n && s[R - L] == s[R]) R++;
      z[i] = R - L;
      R--;
    } else {
      long long k = i - L;
      if (z[k] < R - i + 1)
        z[i] = z[k];
      else {
        L = i;
        while (R < n && s[R - L] == s[R]) R++;
        z[i] = R - L;
        R--;
      }
    }
  }
  return z;
}
vector<long long> patterMatch(string text, string pattern) {
  string key = pattern + '$' + text;
  vector<long long> z = zFunction(key);
  vector<long long> res;
  long long m = pattern.size();
  for (long long i = m + 1; i < key.size(); ++i)
    if (z[i] == m) res.push_back(i - m - 1);
  return res;
}
vector<long long> kaden(vector<long long> &arr) {
  vector<long long> kaden(arr.size());
  kaden[0] = arr[0];
  for (long long i = 1; i < arr.size(); ++i)
    kaden[i] = max(arr[i], arr[i] + kaden[i - 1]);
  return kaden;
}
long long digitSum(long long x) {
  long long ds = 0;
  while (x) {
    ds += x % 10;
    x /= 10;
  }
  return ds;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> arr(n);
    for (long long i = 0; i < n; ++i) cin >> arr[i];
    for (long long i = 0; i < n; ++i) arr[i]--;
    long long pos = 0;
    while (pos < n) {
      long long next = min_element(arr.begin() + pos, arr.end()) - arr.begin();
      long long el = arr[next];
      arr.erase(arr.begin() + next);
      arr.insert(arr.begin() + pos, el);
      if (pos == next)
        pos = next + 1;
      else
        pos = next;
    }
    for (long long i = 0; i < n; ++i) arr[i]++;
    printArr(arr);
  }
  return 0;
}
