Construct the sequence arr[1], arr[2], ... by the following rules. For i=1 we put arr[1]=1. Now let i >= 2. Then arr[i] is the least positive integer such that the following two conditions hold

(i) arr[i] > arr[i - 1];

(ii) for all k, j < i we have arr[i] is not equal to n1 * arr[k] - n2 * arr[j].

Find the first n terms of this sequence.

**Input**:The first line contains a single integer T, the number of test cases. T test cases follow. The only line of each test case contains three integers n1, n2 and n.

**Output:**For each test case, output a single line containing the numbers arr[1], arr[2], ..., arr[n] generated by the rules given in the problem statement and numbers n1, n2. Separate any two consecutive numbers in a line by a single space.

**Constraints**:

Time limit=1 sec

1 <= T <= 50

1 <= a, b <= 50

1 <= n <= 1000

**Example**

Input:

3

2 1 10

1 1 5

4 2 4

Output:

1 2 4 5 10 11 13 14 28 29

1 2 3 4 5

1 3 4 5

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

the_coder95 | 465 |

thanuvinu94 | 388 |

Senbonzakura_Kageyoshi | 297 |

adityasuman2025 | 277 |

PrakharBansal1 | 258 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1064 |

samay_kam_hai | 724 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.