After getting bored of playing video games, Mike decided to go hiking. Like any good hiker, he brought a map along with him. However, shortly after setting out for the hike, Mike was caught in a rainstorm. Once he found shelter under a nearby tree, Mike realized his map had gotten drenched as well!
Determined to finish his hike, Mike wants you to reconstruct the map. The map is represented as an array of integers, each indicating the elevation at a particular point. Remembering that certain sections of the map were uphill or downhill, Mike will give you
- If
, the subarray from index to index is strictly increasing. - If
, the subarray from index to index is strictly decreasing.
Mike also has some additional requirements for the map: First of all, he tells you that the trail is never flat, so no two adjacent elements can be equal. Second of all, each element must be a positive integer not exceeding
Help Mike reconstruct his map, or tell him that it is impossible to do so.
Constraints
Subtask 1 [50%]
If your submission outputs a valid map but does not minimize the maximum element, you will receive
Subtask 2 [50%]
No additional constraints.
If your submission outputs a valid map but does not minimize the maximum element, you will receive
Input Specification
The first line contains
The
Output Specification
If no valid output exists, output
Otherwise, output one line containing
If there are multiple valid answers, you may output any of them.
Sample Input 1
5 2
1 1 3
2 3 5
Sample Output 1
1 2 3 2 1
Sample Input 2
3 3
1 1 2
1 2 3
2 1 3
Sample Output 2
-1
Comments