Dima and Two Sequences

Little Dima has two sequences of points with integer coordinates: sequence (a 1, 1), (a 2, 2), …, (a n, n) and sequence (b 1, 1), (b 2, 2), …, (b n, n).

Now Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled from these sequences, such that the x-coordinates of points in the assembled sequence will not decrease. Help him with that. Note that each element of the initial sequences should be used exactly once in the assembled sequence.

Dima considers two assembled sequences (p 1, q 1), (p 2, q 2), …, (p n, q n) and (x 1, y 1), (x 2, y 2), …, (x n, y n) distinct, if there is such i (1 ≤ i ≤ 2·n), that (p i, q i) ≠ (x i, y i).

As the answer can be rather large, print the remainder from dividing the answer by number m.

Input

The first line contains integer n (1 ≤ n ≤ 105). The second line contains n integers a 1, a 2, …, a n (1 ≤ a i ≤ 109). The third line contains n integers b 1, b 2, …, b n (1 ≤ b i ≤ 109). The numbers in the lines are separated by spaces.

The last line contains integer m (2 ≤ m ≤ 109 + 7).

Output

In the single line print the remainder after dividing the answer to the problem by number m.

Examples

input

1
1
2
7

output

1

input

2
1 2
2 3
11

output

2

Note

In the first sample you can get only one sequence: (1, 1), (2, 1).

In the second sample you can get such sequences : (1, 1), (2, 2), (2, 1), (3, 2); (1, 1), (2, 1), (2, 2), (3, 2). Thus, the answer is 2.

Solution:

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>

using namespace std;

int n, i, j, md;
int f[444444], g[444444], a[444444], b[444444];

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) scanf("%d", a+i);
  for (i=0;i<n;i++) scanf("%d", b+i);
  scanf("%d", &md);
  int div2 = 0;
  for (i=0;i<n;i++)
    if (a[i] == b[i]) div2++;
  sort(a, a+n);
  sort(b, b+n);
  f[0] = 1;
  g[0] = 0;
  for (i=1;i<=2*n;i++) {
    g[i] = g[i-1];
    int x = i;
    while (x % 2 == 0) {
      x /= 2;
      g[i]++;
    }
    f[i] = (long long)f[i-1]*x % md;
  }
  int ans = 1, mul2 = 0;
  i = 0, j = 0;
  while (i < n || j < n) {
    int u;
    if (i == n) u = b[j]; else
    if (j == n) u = a[i]; else
    if (a[i] < b[j]) u = a[i];
    else u = b[j];
    int cnt = 0;
    while (i < n && a[i] == u) i++, cnt++;
    while (j < n && b[j] == u) j++, cnt++;
    ans = (long long)ans*f[cnt] % md;
    mul2 += g[cnt];
  }
  for (i=0;i<mul2-div2;i++) ans = (long long)ans*2 % md;
  printf("%d\n", ans);
  return 0;
}