#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> solve(vector<int> v)
{
    vector<vector<int>> cnt(26);
    for (int i = 0; i < v.size(); i++) cnt[__builtin_ctz(v[i])].push_back(i);

    vector<int> v1, v2;

    for (int i = 0; i < 26; i++)
    {
        for (int j = 0; j < ((int)cnt[i].size())/2; j++)
        {
            v1.push_back(cnt[i].back());
            cnt[i].pop_back();
            v2.push_back(cnt[i].back());
            cnt[i].pop_back();
        }
    }

    for (int i = 25; i >= 0; i--) if (!cnt[i].empty())
    {
        v1.push_back(cnt[i].back());
        for (int j = i-1; j >= 0; j--) if (!cnt[j].empty()) v2.push_back(cnt[j].back());
        break;
    }

    v.clear();
    for (int x : v1) v.push_back(x);
    for (int x : v2) v.push_back(x);
    return v;
}