Two friendly frog families are standing on a line of
The frog families are now going on a family trip! The first family wants to stand on the stones numbered from
- If there is at least one stone in the direction that the frog faces and the stone directly in front of the frog does not have a frog on it, hop to that stone.
- If there are at least two stones in the direction that the frog faces, the stone directly in front of the frog is occupied by a frog from the other family, and the stone behind the other frog does not have a frog on it, hop to that stone.
Given these conditions, is it possible for all the frogs to reach their desired stones? If it is, please find the shortest sequence of hops that achieves it.
Constraints
Subtask 1 [10%]
Subtask 2 [40%]
Subtask 3 [50%]
No additional constraints.
Input Specification
The first and only line contains
Output Specification
If it is impossible for all the frogs to reach their desired stones, output
Otherwise, the first line of your output should contain an integer
Then, the
Scoring
For each test case, your output should satisfy the following requirement:
- The integer on the first line of output must be correct.
If the integer on the first line is not
- For each
, there must be a frog on stone and it should be able to perform exactly one of the two hops. - After performing the hops given, the first family of frogs should be on stones
to and the second family of frogs should be on stones to .
If your output satisfies all of the necessary requirements, you will receive Accepted
for that test case. Otherwise, you will receive Wrong Answer
.
Sample Input
2 2
Sample Output
8
1
3
4
2
0
1
3
2
Comments