You have been asked to discover some important properties of one strange sequences set. Each sequence of the parameterized set is given by a recurrent formula:
where n > 1, and the value of F(X,Y) is evaluated by the following algorithm:
- find H = (A1*X*Y + A2*X + A3*Y + A4);
- if H > B1 then H is decreased by C until H ≤ B2;
- the resulting value of H is the value of function F.
The sequence is completely defined by nonnegative constants A1, A2, A3, A4, B1, B2 and C.
One may easily verify that such sequence possess a property that Xp+n = Xp+q+n for appropriate large enough positive integers p and q and for all n ≥ 0. You task is to find the minimal p and q for the property above to hold. Pay attention that numbers p and q are well defined and do not depend on way minimization is done.
The first line contains seven integers: A1, A2, A3, A4, B1, B2 and C. The first two members of sequence (X1 and X2) are placed at the second line. You may assume that all intermediate values of H and all values of F fit in range [0..100000].
An output should consist of two integers (p and q) separated by a space.
0 0 2 3 20 5 7
Problem Author: Alexander Klepinin
Problem Source: Third USU personal programming contest, Ekaterinburg, Russia, February 16, 2002