시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB284450.000%

문제

You are given an array $A$ containing $N$ non-negative integers. You have to construct a binary grid of size $N \times M$ such that:

  • for any cell with value $1$, any of its adjacent cells, i.e. cells that share one of its four sides, must not have the value $1$.
  • the number of cells with value $1$ in row $i$ is exactly $A_i$.

Find any such binary grid or tell that it's impossible to construct.

입력

The first line contains two integers $N$ and $M$ ($1 \leq N, M \leq 1000$). The next line contains $N$ integers containing $A_i$ ($0 \leq A_i \leq M$).

출력

Output $N$ lines, each containing $M$ characters of either 0 or 1 representing the binary grid you constructed. If multiple construction exists, you may output any of them. If such a grid does not exist, output $-1$.

예제 입력 1

6 7
4 3 2 2 3 4

예제 출력 1

1010101
0101010
1010000
0000101
0101010
1010101

예제 입력 2

2 2
2 2

예제 출력 2

-1