401526: GYM100488 M Construct a Permutation

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

Description

M. Construct a Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Alex has recently learned the algorithm of finding the longest increasing subsequence of the array. The longest increasing subsequence of the array a1, ..., an is the sequence of numbers ai1, ..., aim, where i1 < ... < im and ai1 < ... < aim, and m — the length of the longest increasing subsequence — is the greatest possible. For instance, in the array such a subsequence is . Of course, the array can contain multiple longest increasing subsequences.

Alex has also figured out that the longest decreasing subsequence can be found by just reversing the array. To verify his guesses and the algorithm's work at all he decided to construct such a permutation that its longest increasing subsequence has length a and its longest decreasing one has length b. Moreover, the permutation must be the largest possible in order to test the performance of the algorithm more carefully. You are to find such a permutation.

Input

The only line contains two integers a and b (1 ≤ a, b ≤ 500) — the required length of the longest increasing and decreasing subsequences correspondingly.

Output

In the first line output a single integer n — the length of the permutation.

In the second line output the permutation of numbers from 1 to n, satisfying all the requirements.

The length of the permutation n must be the largest possible. If there are multiple solutions, output any of them.

ExamplesInput
2 1
Output
2
1 2
Input
2 2
Output
4
2 4 1 3

加入题单

算法标签: