Product Oriented Recurrence
시간 제한1초메모리 제한1024 MB
c의 거듭제곱 인수가 곱해지는 곱셈 점화식의 n번째 항을 10억 7로 나눈 나머지로 구한다. n은 10^18까지다.
문제
Let for .
You have given integers , , , , and . Find .
입력
The only line contains five integers , , , , and (, , , , ).
출력
Print .
힌트
In the first example, , .
In the second example, .