SP25891 PCLNMBR - Peculiar Number

Description

Ajoy has got some spare time today. He is using this spare time to think of a particular kind of number. He calls it ‘Peculiar Number’. A peculiar number is define by three integers A, B and C and has the following characteristics. 1) If a number is a multiple of A but not a multiple of B then it is a peculiar number. 2) If a number is a multiple of both A and B then it will be a peculiar number only if it is also a multiple of number C. Otherwise it is not a peculiar number. Now, Ajoy is trying to find the Nth peculiar number for a fixed A, B and C. But Ajoy does not have all day. So he needs your help to solve the problem.

Input Format

First line of the input contains four integers A, B, C and M where (1

Output Format

For each query, print the Nth peculiar number.