#P3060. Product Oriented Recurrence

Product Oriented Recurrence

说明

Let fx=c2x6fx1fx2fx3 f_{x} = c^{2x-6} \cdot f_{x-1} \cdot f_{x-2} \cdot f_{x-3} for x4 x \ge 4 . | You have given integers n n , f1 f_{1} , f2 f_{2} , f3 f_{3} , and c c . Find fnmod(109+7) f_{n} \bmod (10^{9}+7) . |

输入格式

The only line contains five integers n n , f1 f_{1} , f2 f_{2} , f3 f_{3} , and c c ( 4n1018 4 \le n \le 10^{18} , 1f1 1 \le f_{1} , f2 f_{2} , f3 f_{3} , c109 c \le 10^{9} ).

输出格式

Print fnmod(109+7) f_{n} \bmod (10^{9} + 7) .

样例

输入数据 1

5 1 2 5 3

输出数据 1

72900

样例

输入数据 2

17 97 41 37 11

输出数据 2

317451037

提示

|In the first example, f4=90 f_{4} = 90 , f5=72900 f_{5} = 72900 . | In the second example, f172.28×1029587 f_{17} \approx 2.28 \times 10^{29587} . |