#C888. Planting Trees on a Circular Road

    ID: 52910 Type: Default 1000ms 256MiB

Planting Trees on a Circular Road

Planting Trees on a Circular Road

You are given a circular road of length N meters. Your task is to plant M trees along the road such that the distance between any two consecutive trees is exactly P meters. The trees are planted starting from position 0, and subsequent trees are placed in multiples of P. However, if it is not possible to plant M trees under these conditions, you should output -1.

Note that for the trees to be planted successfully, the necessary condition is given by the inequality:

M×PNM \times P \leq N

If this condition is not satisfied, then it is impossible to fit M trees along the road with the required spacing.

For each test case, you will be given three integers N, M, and P as input. Your program should output the positions of the trees in the order they are planted (starting from 0) separated by spaces, or -1 if planting the trees is not possible.

inputFormat

The input is read from stdin. The first line contains an integer T representing the number of test cases. Each of the following T lines contains three space-separated integers N, M, and P, where:

  • N is the length of the circular road in meters.
  • M is the number of trees to be planted.
  • P is the distance between any two consecutive trees in meters.

outputFormat

For each test case, output a single line. If it is possible to plant the trees, output the positions of the trees separated by a single space. If it is not possible, output -1.

All output should be written to stdout.

## sample
3
100 4 25
90 4 25
50 10 5
0 25 50 75

-1 0 5 10 15 20 25 30 35 40 45

</p>