Andrew and the Meatballs again
Andrew likes meatballs very much as you know.
He has N plates of meatballs, here the ith plate contains exactly i meatballs. Andrew wants to take exactly K plates to his trip to Las Vegas.
On this occasion, he wants to choose the K plates by a strange way: if both ith and jth plates are chosen, then i and j must not be relative prime, for all 1 ≤ i < j ≤ N.
Please help him to choose K plates. Output one of the possible choices.
The first line of the input contains an integer T, denoting the number of test cases. The description of T test cases follows. The first line and only line of each test case contains two space-separated integers N and K.
For each test case, output K distinct integers, denoting the number of selected plates, where the plates are numbered from 1 to N. If there are multiple solutions, any one will do. If it is impossible to choose K plates, print only one integer -1.
- 1 ≤ T ≤ 7
- 1 ≤ K ≤ N ≤ 777
Input: 2 100 3 100 100 Output: 45 63 35 -1
Example case 1: One of the possible choices is that he takes 45th plate, 63rd plate, and 35th plate. Because
GCD(45, 63) = 9,
GCD(45, 35) = 5,
GCD(63, 35) = 7.
Example case 2: He must choose all N = K plates in this case. But, for example, the pair of 3rd plate and 5th plate does not satisfy his desire. So it is impossible to choose K plates.
|Tags||ad-hoc, cook33, simple, witua|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.5, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.