12421 - password-Z   

Description

A sequence from 1 to N is written in a  zigzag pattern on a given number  of rows .

For example, N = 12, R = 3. You should encode it as 


And if N = 12, R = 4. You should encode it as 

In the end, you should output this sequence in order like 1 5 9 2 4 6 8 10 12 3 7 11 .

seperated by space and end by space, no need to change line.

Input

Two number N & R.

N  is the length of sequence.

R is the numbers of row.

Output

An encoded sequence in row-major order.

Sample Input  Download

Sample Output  Download

Tags




Discuss