409428: GYM103540 B Gift

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Gifttime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

You want to give your friend a gift on his birthday. The gift is a box of $$$n$$$ candies. You went to a candy shop and there are $$$m$$$ flavors of candy. The $$$i$$$th flavor is defined by the $$$i$$$th letter in the alphabet. i.e. first flavor is defined by $$$a$$$, second flavor is defined by $$$b$$$, third flavor is defined by $$$c$$$, $$$\cdots$$$ and so on.

Print all possible choices for candy box. Two candy box will be different if for any $$$i$$$, $$$i$$$th candy flavor in two boxes are different.

Print them in lexicographic order.

Input

Only line in the input contains two integers, $$$n$$$, $$$m$$$ ($$$1 \leq n \leq 9$$$, $$$1 \leq m \leq 6$$$)

Output

First line of the output should contain one integer $$$k$$$ — number of possible choices.

Each of the next $$$k$$$ lines should contain a string of length $$$n$$$ denoting the choice. They should be in lexicographic order.

ExamplesInput
3 2
Output
8
aaa
aab
aba
abb
baa
bab
bba
bbb
Input
1 1
Output
1
a
Input
1 2
Output
2
a
b

Source/Category

加入题单

上一题 下一题 算法标签: