SMPDIV - Divisibility


Print all integers ai such that ai is divisible by x and not divisible by y, where 1 < ai < n < 100000.

Input

First, you are given t (t < 100) - the number of test cases. In each of the following t lines, 3 integers: n x y.

You might assume also that x < n and x is not divisible by y.

Output

In each of the following t lines, numbers requested in the problem description in the separated by a single space in ascending order.

Example

Input:
2
7 2 4
35 5 12
Output:
2 6
5 10 15 20 25 30

hide comments
sabbirnoncoder: 2017-06-19 16:08:24

AC in 1st go

shivam_mnnit: 2017-05-05 20:14:05

i am getting a run time memory overflow problem . how do i solve it??

tasin_hoque: 2017-01-24 07:55:12

Thank you spoj for this easy problem!

priyance: 2016-10-31 20:36:53

Can anyone help me solve this problem as it is creating problem while reading the inputs and bcoz of that output is coming wrong?

peanuts3005: 2016-07-29 08:57:43

AC in 1st go
EASY

liuxueyang: 2016-07-16 14:47:26

AC in the 1st go in common lisp.
@aman25 Just loop from x to n by step x, if x mod y != 0, then print it. Hope it helps.

aman25: 2016-07-06 16:46:56

i am getting runtime error: Segmentation fault. help

lifecoderr: 2016-06-12 10:31:54

The question doesn't specify that there must be a space at the end of 'each line'.
It took me a lot of time to analyse what's going wrong.

rayhan50001: 2016-06-08 17:07:35

AC in 1st Go.. Easy One..

salvatore13: 2016-04-09 20:23:32

solved it in less than 10 minutes, very, very easy. I will post essential line of my code
if((x*i) % y != 0)
thats all you need to solve it

Last edit: 2016-04-09 20:24:30

Added by:kuszi
Date:2013-08-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64