//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
// swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
// g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include<bits/stdc++.h>
#include "swaps.h"
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
void solve(int n, int Q){
vector<pii>v[20];
for(int i=0;i<9;i++){
vector<int>marc(n+1,0);
for(int j=1;j+(1<<i)<=n;j++){
// cerr << "(" << j << ',' << j+(1<<i) << ")\n";
if(marc[j]) v[2*i+1].push_back({j,j+(1<<i)});
else{
v[2*i].push_back({j,j+(1<<i)});
marc[j]=marc[j+(1<<i)]=1;
}
}
}
for(int i=17;i>=0;i--){
vector<int>marc(n+1,0);
for(pii p : v[i]) schedule(p.fi,p.se), marc[p.fi]++, marc[p.se]++;
for(int j=1;j<=n;j++) assert(marc[j]<=1);
vector<int>a=visit();
}
vector<int>ans;
for(int i=1;i<=n;i++) ans.push_back(i);
answer(ans);
}