AtCoder Regular Contest 127
B
Ternary Strings
AtCoder
⌀ 1594
原题
← AC →
翻译中…

Problem Statement

翻译中…

Given are integers $N$ and $L$. Find a tuple of $3N$ strings $(S_1,S_2,\cdots,S_{3N})$ that satisfies all of the following conditions.

翻译中…
  • $S_i$ is a string of length $L$ consisting of 0, 1, 2.
  • All $S_i$ are pairwise distinct.
  • For every $j$ ($1 \leq j \leq L$) and every $c=$0, 1, 2, the following holds.
  • For exactly $N$ of the strings $S_i$, the $j$-th character is $c$.
  • Let $t$ be the lexicographically largest string among $S_1,S_2,\cdots,S_{3N}$. $t$ for this tuple is the lexicographically smallest among all strings that $t$ can be.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 5 \times 10^4$
  • $1 \leq L \leq 15$
  • $3N \leq 3^L$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N L

翻译中…

Output

翻译中…

Print the answer in the following format:

翻译中…

S_1
S_2
\vdots
S_{3N}

翻译中…

If there are multiple solutions satisfying the conditions, any of them will be accepted.

翻译中…

样例

Input #1
2 2
Output #1
00
02
11
12
20
21
This Sample Output satisfies all conditions. For example, there are two strings whose second character is `0`. Also, we have $t=$`21` in this sample, and $t$ is never lexicographically smaller than this.
题目信息
题号
arc127_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。