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

using ui=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using u128=__uint128_t;
using ld=long double;

void solve()
{//1可以是任何数的因子 所以我们可以构造数组使其异或和为1 易知奇数个1异或结果为1 所以当n为奇数时我们直接输出n个1即可
//当n为偶数时 我们知道n肯定是n的因子 我们可以构造数组使其异或和为n 我们又知道0异或n等于n 多个0异或的结果还是0 所以我们可以输出n-1个0 最后输出n
    int n;
    cin >> n;
    if(n%2==1)
    {
        for(int i=0;i<n;i++) cout << 1 << " ";
        cout << "\n";
    }
    else
    {
        for(int i=0;i<n-1;i++) cout << 0 << " ";
        cout << n << "\n";
    }
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	cin >> t;
	
	while(t--)
	{
		solve();
	}
	return 0;
}