program takmicenje;
var
a:array [1..1000, 1..1000] of integer;
t:array [1..10, 1..3] of integer;
n,i,j,k,p:integer;
begin
readln(n);
for i:=1 to n do
readln(t[i,1],t[i,2]);
for i:=1 to n do
if t[i,1] <> t[i,2]
then
writeln(-1)
else
begin
for k:=1 to t[i,1] do
begin
writeln;
for p:=1 to t[i,1] do
begin
if k=1 then
write(1,' ')
else
if k=t[i,1] then
write(1,' ')
else
if p=1 then
write(1,' ')
else
if p=t[i,1] then
write(1,' ')
else
if p> t[i,1]-k+1 then
write(1,' ')
else
write(0,' ');
end;
end;
end;
end.