Given an array A of N integers A1, A2, A3, ..., AN. This array is generated by the following formula:
A1 = S
Ai = (C1 * Ai - 1 + C2) mod M, for i = 2..N
Your task is very simple. Find out K smallest integers among the N generated integers.
First line of input consist number of test case T (T ≤ 20). Each of the next T lines describe a test case. Each test case consists of six numbers: N, K, S, C1, C2, M where:
For the ith test case, you should print K smallest numbers in ascending order on the ith line of output. The numbers should be seperated by a single space.
2
10000 9 71 197 5 91723
2014 4 27 279 64 97264
3 4 4 24 40 40 41 49 71
27 77 221 251
| Название |
|---|


