CF789B Masha and geometric depression
Description
Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.
You are given geometric progression $ b $ defined by two integers $ b_{1} $ and $ q $ . Remind that a geometric progression is a sequence of integers $ b_{1},b_{2},b_{3},... $ , where for each $ i>1 $ the respective term satisfies the condition $ b_{i}=b_{i-1}·q $ , where $ q $ is called the common ratio of the progression. Progressions in Uzhlyandia are unusual: both $ b_{1} $ and $ q $ can equal $ 0 $ . Also, Dvastan gave Masha $ m $ "bad" integers $ a_{1},a_{2},...,a_{m} $ , and an integer $ l $ .
Masha writes all progression terms one by one onto the board (including repetitive) while condition $ |b_{i}|
Input Format
The first line of input contains four integers $ b_{1} $ , $ q $ , $ l $ , $ m $ (- $ 10^{9}
Output Format
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
Explanation/Hint
In the first sample case, Masha will write integers $ 3,12,24 $ . Progression term $ 6 $ will be skipped because it is a "bad" integer. Terms bigger than $ 24 $ won't be written because they exceed $ l $ by absolute value.
In the second case, Masha won't write any number because all terms are equal $ 123 $ and this is a "bad" integer.
In the third case, Masha will write infinitely integers $ 123 $ .