Function

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

You are given a function f,:,N_0N_0f \\, : \\, \mathbb{N}\_0 \to \mathbb{N}\_0 defined as below. (N_0\mathbb{N}\_0 denotes the set of non-negative integers.)

  • f(0)=a_0f(0) = a\_0
  • f(i)=a_if(i 1)f(i) = a\_i^{f(i - 1)} (i 1i \ge 1)

Find the value of f(n)f(n) modulo mm.

입력

The first line contains a single integer nn.

The second line contains n+1n + 1 integers a_0,,a_1,,,,a_na\_0, \\, a\_1, \\, \cdots, \\, a\_n.

The third line contains a single integer mm.

출력

Print the value of f(n)f(n) modulo mm.

제한

  • 0 n20 \le n \le 2
  • 1a_i2×1091 \le a\_i \le 2 \times 10^9 (0in0 \le i \le n)
  • 2m<2×1092 \le m < 2 \times 10^9; mm is a prime number.
  • All values in input are integers.

힌트

As a note, the exact value of 9999^{9^9} has a whopping 369,693,700369 \\, 693 \\, 700 digits.