t = int(input())
a = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]
for _ in range(t):
n, m = list(map(int, input().split()))
arr = [[0] * m for _ in range(n)]
for i in range(n):
for j in range(m):
print(a[i % 4][j % 4], end=' ')
print()
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <functional> // for less
#define ll long long int
#define mpl map<ll,ll>
#define mpc map<char,ll>
#define fr(a,b) for(ll i=a;i<b;i++)
#define rfr(a,b) for(ll i=a;i>b;i--)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define rev(x) reverse(all(x))
#define bitcnt(x) __builtin_popcountll(x)
#define read(x) fr(0,x.size()) cin>>x[i];
#define printv(x) fr(0,x.size()) cout<<x[i]<<" ";
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define py cout<<"YES\n";
#define pm cout<<"-1\n";
#define pn cout<<"NO\n";
#define pii pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpl vector<pl>
#define vvi vector<vi>
#define vvl vector<vl>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// using namespace __gnu_pbds;
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_multiset;
struct sparse_table{
vector<vector<ll>> mat;
ll n,m;
vector<ll> p2;
void init(ll _n,ll _m)
{
n=_n;
m=_m;
mat.resize(n);
fr(0,n)
mat[i].resize(m);
p2.resize(n+1);
p2[1]=0;
fr(2,n+1)
p2[i]=p2[i/2]+1;
}
void build(vector<ll> &a)
{
fr(0,n)
mat[i][0]=a[i];
for(ll j=1;j<m;j++)
{
for(ll i=0;(i+(1<<j))<=n;i++)
{
mat[i][j]=(mat[i][j-1]+mat[i+(1<<(j-1))][j-1]);
}
}
}
ll minQuery(ll l,ll r)
{
ll len=(r-l+1);
ll pw=p2[len];
return min(mat[l][pw],mat[r-(1<<pw)+1][pw]);
}
ll sumQuery(ll l,ll r)
{
ll ans=0;
for(ll j=m;j>=0;j--)
{
if((1<<j)<=(r-l+1))
{
ans+=mat[l][j];
l+=(1<<j);
}
}
return ans;
}
};
class Graph{
ll V;
vector<vector<ll>> li;
public:
Graph(ll v)
{
V=v;
li.resize(V+1);
}
void addEdge(ll x,ll y)
{
li[x].pb(y);
li[y].pb(x);
}
void printAdj()
{
for(ll i=1;i<=V;i++)
{
cout<<i<<"--> :";
for(auto ver:li[i])
cout<<ver<<" ";
cout<<endl;
}
}
void bfs(ll source)
{
vector<ll> vis(V+1,0);
queue<ll> q;
vector<ll> parent(V+1,-1);
vector<ll> dis(V+1,0);
q.push(source);
vis[source]=1;
dis[source]=0;
while(!q.empty())
{
ll f=q.front();
q.pop();
for(auto ver:li[f])
{
if(!vis[ver])
{
q.push(ver);
vis[ver]=1;
dis[ver]=dis[f]+1;
parent[ver]=f;
}
}
}
}
};
vl sieve(10000001,1);
vector<ll> fact(100005,0);
void era(ll n)
{
for(ll i=2;i*i<=10000000;i++)
{
if(sieve[i]==1)
{
for(ll j=i*i;j<=10000000;j+=i)
{
sieve[j]=0;
}
}
}
for(ll i=2;i<=n;i++)
if(sieve[i])
cout<<i<<" ";
cout<<endl;
}
ll binpow(ll a,ll b)
{
ll ans=1;
while(b>0)
{
if(b&1)
{
ans=(ans*a)%mod;
}
b>>=1;
a=(a*a)%mod;
}
return ans;
}
ll inv(ll n)
{
return binpow(n,mod-2);
}
ll nCr(ll n,ll r)
{
if(n==r||r==0)
return 1;
else
{
ll num=fact[n];
ll den=(fact[n-r]*fact[r])%mod;
return (num*inv(den))%mod;
}
}
ll sumd(ll n)
{
ll ans=0;
while(n>0)
{
ans+=n%10;
n/=10;
}
return ans;
}
int main()
{
fact[1]=1;
fact[0]=1;
fr(2,100005)
{
fact[i]=(fact[i-1]*i)%mod;
}
ll t;
cin>>t;
while(t--)
{
ll n,m;
cin>>n>>m;
for(ll i=1;i<=n;i++)
{
for(ll j=1;j+3<=m;j+=4)
{
if(i%4==1||i%4==0)
{
cout<<"1 0 0 1 ";
}
else
{
cout<<"0 1 1 0 ";
}
}
if(m%4==2)
{
if(i%4==1||i%4==0)
{
cout<<"1 0 ";
}
else
cout<<"0 1 ";
}
cout<<endl;
}
}
}
1370A - Maximum GCD | 149A - Business trip |
34A - Reconnaissance 2 | 59A - Word |
462B - Appleman and Card Game | 1560C - Infinity Table |
1605C - Dominant Character | 1399A - Remove Smallest |
208A - Dubstep | 1581A - CQXYM Count Permutations |
337A - Puzzles | 495A - Digital Counter |
796A - Buying A House | 67A - Partial Teacher |
116A - Tram | 1472B - Fair Division |
1281C - Cut and Paste | 141A - Amusing Joke |
112A - Petya and Strings | 677A - Vanya and Fence |
1621A - Stable Arrangement of Rooks | 472A - Design Tutorial Learn from Math |
1368A - C+= | 450A - Jzzhu and Children |
546A - Soldier and Bananas | 32B - Borze |
1651B - Prove Him Wrong | 381A - Sereja and Dima |
41A - Translation | 1559A - Mocha and Math |