#P1182E. Product Oriented Recurrence

Product Oriented Recurrence

Description

Let fx=c2x6fx1fx2fx3f_{x} = c^{2x-6} \cdot f_{x-1} \cdot f_{x-2} \cdot f_{x-3} for x4x \ge 4.

You have given integers nn, f1f_{1}, f2f_{2}, f3f_{3}, and cc. Find fnmod(109+7)f_{n} \bmod (10^{9}+7).

The only line contains five integers nn, f1f_{1}, f2f_{2}, f3f_{3}, and cc (4n10184 \le n \le 10^{18}, 1f11 \le f_{1}, f2f_{2}, f3f_{3}, c109c \le 10^{9}).

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

Input

The only line contains five integers nn, f1f_{1}, f2f_{2}, f3f_{3}, and cc (4n10184 \le n \le 10^{18}, 1f11 \le f_{1}, f2f_{2}, f3f_{3}, c109c \le 10^{9}).

Output

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

Samples

输入数据 1

5 1 2 5 3

输出数据 1

72900

输入数据 2

17 97 41 37 11

输出数据 2

317451037

Note

In the first example, f4=90f_{4} = 90, f5=72900f_{5} = 72900.

In the second example, f172.28×1029587f_{17} \approx 2.28 \times 10^{29587}.