#ifdef LOCAL
    #define _GLIBCXX_DEBUG
#endif // LOCAL

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <queue>
#include <iomanip>
#include <iterator>
#include <fstream>
#include <cstdlib>
#include <random>
#include <climits>
#include <chrono>

using namespace std;

#define int long long
#define f first
#define s second
#define fi first
#define se second
#define p_b push_back
#define e_b emplace_back
#define pw(x) (1LL<<((int)x))
#define sz(x) (ll)x.size()
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using ll = long long;
using ul = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

const ll N = 2e5 + 5, mod = 1e9+7;

template<class T> inline T sqr(T x) {return x * x;}
template<class T> inline void amin(T &a, T b) {a = a < b ? a : b;}
template<class T> inline void amax(T &a, T b) {a = a > b ? a : b;}
template<class T> inline void smod(T &a, T b) {a = a + b >= mod ? a + b - mod : a + b;}
template<class T> inline void dmod(T &a, T b) {a = a - b >= 0 ? a - b : a - b + mod;}

mt19937 rnd(time(0));

vector<int> pos;
set<int> slay[20];
unordered_map<int, int> cc;

void build(int sl, int cur, int l, int r) {
    cc[cur]++;
//    cout << l << ' ' << r << ' ' << sl << ' ' << cur << ' ';
    if (l == r) {
        pos[l] = cur;
        return;
    }
    auto it = slay[sl].lower_bound(cur);
//    if (it == slay[sl].end())
//        return 0;
//    cout << *it << '\n';
    int m = (l + r) / 2;
    build(sl + 1, cur, l, m),
    build(sl + 1, it != slay[sl].end() ? *it : 0, m + 1, r);
    if (it != slay[sl].end())
        slay[sl].erase(it);
//    return !L || !R;
}

ll go(int l, int r) {
    if (l == r) {
        cc[pos[l]]++;
        return pos[l];
    }
    ll m = (l + r) / 2;
    ll cur = min(go(l, m), go(m + 1, r));
    cc[cur]++;
    return cur;
}

void solve() {
    ll n;
    cin >> n;
    pos.clear();
    cc.clear();
    for (int i = 0; i < __lg(n) + 1; i++)
        slay[i].clear();
    vector<int> a(n);
    unordered_map<int, int> c;
    vector<int> ans;
    int k;
    for (auto &i : a)
        cin >> i, c[i]++;
    if (n == 1) {
        cout << a[0];
        return;
    }
    k = __lg(n + 1);
    sort(all(a));
    ans.p_b(a[0]);
    for (int i = 1; i < n; i++) {
        if (a[i] != a[i - 1])
            ans.p_b(a[i]);
    }
    int cnt = 1, cur = 1;
    while (cnt != n) {
        cur *= 2;
        cnt += cur;
    }
    if (sz(ans) != cur) {
        cout << -1;
        return;
    }
    pos.resize(cur);
    vector<pii> h;
    for(auto [i, j] : c)
        h.p_b({j, i});
    sort(all(h), [](pii &a, pii &b){
        return a.f != b.f
        ? a.f > b.f
        : a.s < b.s;
    });
//    cout << h[0].f << ' ' << h[0].s << ' ' << k << '\n';
    if (h[0].f != k) {
        cout << -1;
        return;
    }
    pos[0] = h[0].s;
    cnt = 1;
    k--;
    int sl = 1;
    for (int i = 1; i < sz(h); i += cnt, cnt *= 2, k--, sl++) {
        cur = pw(k - 1);
        for (int j = i; j < i + cnt; j++, cur += pw(k)) {
            if (h[j].f != k) {
                cout << -1;
                return;
            }
            slay[sl].insert(h[j].s);
        }
    }
    build(1, h[0].s, 0, sz(pos) - 1);
    if (cc != c) {
        cout << -1;
        return;
    }
//    go(0, sz(pos) - 1);
//    for (auto [i, j] : cc)
//        cout << i << ' ' << j << '\n';
//    if (cc != c) {
//        cout << -1;
//        return;
//    }
    for (auto i : pos)
        cout << i << ' ';
}

main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    #endif // LOCAL
    int t = 1;
    #ifdef LOCAL
        cin >> t;
    #endif // LOCAL
    while (t--) {
        solve();
        cout << '\n';
    }
    #ifdef LOCAL
        cout << "\n\n===\nTime : " << (long double)clock() / CLOCKS_PER_SEC << '\n';
    #endif // LOCAL
}
