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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education