Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/navbat-doira-boylab-sanash

Counting around a circle

Easy 1000 ms 128 MB 29%
Share

$n$ people stand in a circle, numbered from $1$ to $n$. Counting starts from person $1$: $k$ people are counted clockwise, and the $k$-th person counted leaves the circle. The next count starts from the person after them, and so on, until everyone has left. Determine the order in which the people leave.

Numbered people in a circle: the counting direction and the order of those who left are marked

Input

One line with two positive integers: $n$ and $k$.

Output

One line with $n$ numbers separated by spaces — the order of leaving.

Note

$1 \le n, k \le 2000$

Examples

Input #1
7 3
Output #1
3 6 2 7 5 1 4
Input #2
1 1
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.