table can be addressed as a square shape with stature h and width w, isolated into h×w cells. Let (i,j) signify the cell in the I-th line and the j-th segment of the square shape (1≤i≤h; 1≤j≤w). Into every cell of the table you can either put a plate or keep it unfilled. As every visitor must be situated close to their plate, you
Correct answer will be upvoted else downvoted.
table can be addressed as a square shape with stature h and width w, isolated into h×w cells. Let (i,j) signify the cell in the I-th line and the j-th segment of the square shape (1≤i≤h; 1≤j≤w).
Into every cell of the table you can either put a plate or keep it unfilled.
As every visitor must be situated close to their plate, you can just put plates on the edge of the table — into the first or the last line of the square shape, or into the first or the last segment. Officially, for every cell (i,j) you put a plate into, no less than one of the accompanying conditions should be fulfilled: i=1, i=h, j=1, j=w.
To make the visitors agreeable, no two plates should be placed into cells that have a typical side or corner. All in all, if cell (i,j) contains a plate, you can't place plates into cells (i−1,j), (i,j−1), (i+1,j), (i,j+1), (i−1,j−1), (i−1,j+1), (i+1,j−1), (i+1,j+1).
Put whatever number plates on the table as could be expected under the circumstances without disregarding the principles above.
Input
The principal line contains a solitary integer t (1≤t≤100) — the number of experiments.
Every one of the accompanying t lines depicts one experiment and contains two integers h and w (3≤h,w≤20) — the stature and the width of the table.
Output :For each experiment, print h lines containing w characters each. Character j in line I should be equivalent to 1 in case you are placing a plate into cell (i,j), and 0 in any case. In case there are various replies, print any.
Step by step
Solved in 3 steps with 1 images