Hide

Problem B
Elliptic Curve Point Multiplication

Languages en is

Let p be a prime and a,bFp such that 4a3+27b20(modp). Let n0 be an integer and P=(x,y) be a point on the elliptic curve E:y2=x3+ax+b. Calcuate nP given p,a,b,x and y.

Input

Input is three lines. First line consists of three integers, 0<p<2311, 0a<p and 0b<p, where p is a prime. Second line consist of one integer 0n2631. Third line consists of two integers 1x2,y2<2311 where (x2,y2)=(1,1) is the point at infinity.

Output

Output one line with the coordinates of nP seperated by space. Both coordinates should be 1 if the result is the point at infinity.

Sample Input 1 Sample Output 1
5 1 1
4
0 4
3 1
Sample Input 2 Sample Output 2
5 1 1
9
0 4
-1 -1
Hide

Please log in to submit a solution to this problem

Log in