problems / 216

GCD-Based Cache Key Distribution

easy gcd number-theory arrays 1400 ms · 256 MB

GCD-Based Cache Key Distribution

You have n cache keys (numbered 1 to n) and k servers (numbered 1 to k). Each key must be assigned to exactly one server based on the greatest common divisor (GCD).

For each key i, assign it to server j where gcd(i, j) is maximum. If multiple servers have the same maximum GCD with key i, choose the server with the smallest ID.

Input

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

Output

Print n integers, where the i-th integer is the server ID (1-indexed) to which key i is assigned.

Constraints

  • 1 ≤ n, k ≤ 10^5

Example 1

Input

3 3

Output

1 2 3

Example 2

Input

4 2

Output

1 2 1 2

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

Hint 1

For a key i and a server j, gcd(i, j) must divide i. So what is the largest value the gcd can take over all servers j from 1 to k?

Hint 2

A server with ID d achieves gcd(i, d) = d whenever d divides i. Find the largest divisor of i that does not exceed k, and check why no server with a smaller ID can match it.

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

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