//本题的大意是给出振幅A和频率F..输出类似这样的形式.
//1
//22
//333
//22
//1
//这里3为振幅..F为多少就输出多少个这样的东西.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<vector>
const int inf = 0x3f3f3f;
using namespace std;
int main()
{
int test,a,f;
while(scanf("%d",&test) != EOF)
{
while(test--)
{
scanf("%d%d",&a,&f);
for(int k = 1 ; k <= f ; k++)
{
for(int i = -(a-1) ; i <= a-1 ; i++)
{
for(int j = 1 ; j <= a - abs(i) ; j++)
{
printf("%d",a - abs(i) );
}
printf("\n");
}
if(f-k)
printf("\n");
}
if(test)printf("\n");
}
}
}
//1
//22
//333
//22
//1
//这里3为振幅..F为多少就输出多少个这样的东西.
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<vector>
const int inf = 0x3f3f3f;
using namespace std;
int main()
{
int test,a,f;
while(scanf("%d",&test) != EOF)
{
while(test--)
{
scanf("%d%d",&a,&f);
for(int k = 1 ; k <= f ; k++)
{
for(int i = -(a-1) ; i <= a-1 ; i++)
{
for(int j = 1 ; j <= a - abs(i) ; j++)
{
printf("%d",a - abs(i) );
}
printf("\n");
}
if(f-k)
printf("\n");
}
if(test)printf("\n");
}
}
}