#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
const int MOD = 1000000007;
const int INF = 1e18;
const int N = 3e5 + 10;
//可以让异或和为n
void solve() {
ll n;
cin>>n;
if(n==1){
cout<<'1'<<endl;
return;
}else{
if(n%2==1){
n=n-1;
for(int i=0;i<n;i++){
cout<<"2 ";
}
cout<<n+1<<endl;
}else{
for(int i=0;i<n-1;i++){
cout<<"0 ";
}
cout<<n<<endl;
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
cin >> T;
while (T--)
solve();
return 0;
}