x = int(input())
for jj in range(x):
n = int(input())
ans = [0] * n
t = set(range(1,n+1))
k = 0
for j in range(1,n+1):
i = j
while i in t:
t.remove(i)
ans[k] = i
k += 1
i *= 2
print(2)
print(' '.join([str(p) for p in ans]))
#include<bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
cout << 2 << endl;
vector<bool> kt(n + 1, false);
for (int i = 1; i <= n; i++){
if (kt[i]) continue;
int now = i;
while (now <= n){
cout << now << " ";
kt[now] = true;
now *= 2;
}
}
cout << endl;
}
int main() {
int t;
cin >> t;
while (t--) solve();
}
1196C - Robot Breakout | 373A - Collecting Beats is Fun |
965A - Paper Airplanes | 863E - Turn Off The TV |
630E - A rectangle | 1104A - Splitting into digits |
19C - Deletion of Repeats | 1550B - Maximum Cost Deletion |
1693A - Directional Increase | 735D - Taxes |
989A - A Blend of Springtime | 339C - Xenia and Weights |
608A - Saitama Destroys Hotel | 1342C - Yet Another Counting Problem |
548A - Mike and Fax | 109A - Lucky Sum of Digits |
864C - Bus | 626B - Cards |
1221A - 2048 Game | 1374D - Zero Remainder Array |
1567C - Carrying Conundrum | 1029C - Maximal Intersection |
922C - Cave Painting | 811C - Vladik and Memorable Trip |
1589C - Two Arrays | 1510K - King's Task |
126B - Password | 462A - Appleman and Easy Task |
839C - Journey | 622A - Infinite Sequence |