problems / 177

Alice Paints Her Fence

easy constructive greedy arrays 1000 ms · 256 MB

Alice Paints Her Fence

Alice wants to paint her fence, which consists of n sections arranged in a line. She has k paint colors available, numbered 1 to k. Her constraint is strict: no two adjacent sections may have the same color. Alice asks you whether it's possible to paint all sections, and if so, to produce a valid coloring.

Input

The first line contains two integers n and k (1 ≤ n ≤ 10^5, 0 ≤ k ≤ 10^5).

Output

If it's possible to color all n sections using at most k colors such that no two adjacent sections have the same color, print a valid coloring as n space-separated integers, where each integer is in the range [1, k]. If it's impossible, print NO. If there are several valid colorings, print any of them.

Notes

The first example has n = 3 and k = 2, requiring a valid 2-coloring of a path of 3 nodes. One valid answer is 1 2 1, which alternates colors; 2 1 2 is accepted too. The second example has n = 2 and k = 1, which is impossible because two adjacent sections cannot both have color 1.

Any correct answer is accepted.

Example 1

Input

3 2

Output

1 2 1

Example 2

Input

2 1

Output

NO

Hints · reveal one at a time if you're stuck

Hint 1

Think about how few colours a row of sections can use. When is it impossible, and does a single section ever need more than one colour?

Hint 2

A left-to-right assignment that always picks a colour different from the previous section's colour is enough, and only two colours are ever needed. Check the k = 0 and n = 1 cases before printing.

report an issue Prefer your own editor? sooks prep 177 (CLI)
Sign in to run code

Run your code on the examples, or submit it against every test.