#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, v3;

    for (int i = 0; i < 26; i++)
    {
        while (cnt[i].size() > 1)
        {
            v1.push_back(cnt[i].back());
            cnt[i].pop_back();
            v2.push_back(cnt[i].back());
            cnt[i].pop_back();
        }
        if (!cnt[i].empty()) v3.push_back(i);
    }
    int n = v3.size();
    swap(v3.back(), v3[n/2+1]);

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

    return v;
} 