logo AlgoBeat OnlineJudge
登录 注册

#209282. [EC Final 2022] Aqre

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Given an matrix, you need to fill it with and , such that:

  • There cannot be four consecutive horizontal or vertical cells filled with the same number.
  • The cells filled with form a connected area. (Two cells are adjacent if they share an edge. A group of cells is said to be connected if for every pair of cells it is possible to find a path connecting the two cells which lies completely within the group, and which only travels from one cell to an adjacent cell in each step.)

Please construct a matrix satisfying the conditions above and has as many s as possible. Output the maximum number of s, and the matrix.

输入格式

The first line contains an integer -- the number of test cases.

For each test case, the first line contains two integers .

It is guaranteed that the sum of over all test cases does not exceed .

输出格式

For each test case, output the maximum number of s in the first line. Then output the matrix in the following lines. If there are multiple solution, output any.

样例

样例输入 1

3
2 2
3 4
3 8

样例输出 1

4
11
11
9
1110
1110
1110
18
11101110
10111011
11011011