Universal Cup Judging System

Universal Cup

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

Description

You are given two integers $N$ and $M$.

Output an $N \times N$ grid whose cells are colored either white or black and which satisfies the following conditions. If no such grid exists, print -1.

  • The sizes of the connected components of white cells in the grid consist of exactly $M$ distinct values.
  • The sizes of the connected components of black cells in the grid consist of exactly $M$ distinct values.

If there are multiple solutions, you may output any of them.

Input

The first line contains two integers $N$ and $M$ ($2 \le N \le 2000$, $1 \le M \le 2000$).

Output

If a grid satisfying the conditions exists, print $N$ lines. On the $i$-th line ($1 \le i \le N$), print a string $s_i$ of length $N$ as follows:

  • If the cell in row $i$, column $j$ ($1 \le j \le N$) of the constructed grid is white, then the $j$-th character of $s_i$ must be . (dot).
  • If the cell in row $i$, column $j$ ($1 \le j \le N$) of the constructed grid is black, then the $j$-th character of $s_i$ must be #.

If no grid satisfying the conditions exists, print -1 on the first line.

Examples

Input 1

4 2

Output 1

###.
..##
##.#
.##.

Input 2

2 3

Output 2

-1

Input 3

12 7

Output 3

.#..#.#.##.#
.#.#..#.##.#
.##...#.##.#
.#.#..#.##.#
.#..#.##..##
......######
######......
#...##..###.
#.##.#.#....
#...##.#....
#.####.#....
#.####..###.

Note

Two white cells $c_1, c_2$ are said to be connected if one can move from one to the other by repeatedly moving to a vertically or horizontally adjacent cell while passing only through white cells.

A set of white cells $S$ is called a connected component if $S$ satisfies the following conditions:

  • Any two cells in $S$ are connected.
  • No white cell not in $S$ is connected to any cell in $S$.

Connected components of black cells are defined similarly.

For each connected component, its size is defined as the number of cells it contains.

Explanation of Sample Output 1: The sizes of the connected components of white cells are the two distinct values 1 and 2. The sizes of the connected components of black cells are also the two distinct values 4 and 6.

problem_17726_15.png

Figure for Sample Output 1

problem_17726_16.png

Figure for Sample Output 3

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#2339EditorialOpen越滑越快,越滑越快ZnPdCoView
#1535EditorialOpen题解jianglyView
#1507EditorialOpenNew Editorial for Problem #17726incentView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.