#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b, long long c) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2) x = (x * y) % c;
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
int array1[200005], arr[200005];
int main() {
  int n, m, num = 0;
  cin >> n;
  vector<pair<int, int> > vec;
  set<pair<int, int> > Set;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    vec.push_back(make_pair(a, i));
  }
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (vec[i - 1].first == a) num++;
    vec.push_back(make_pair(a, i));
  }
  cin >> m;
  sort(vec.begin(), vec.end());
  int last, cnt = 1;
  last = vec[0].first;
  long long ans = 1;
  for (int i = 1; i < vec.size(); i++) {
    if (last == vec[i].first) {
      cnt++;
    } else {
      array1[1]++, array1[cnt + 1]--;
      last = vec[i].first, cnt = 1;
    }
  }
  array1[1]++, array1[cnt + 1]--;
  for (int i = 1; i < 200005; i++) array1[i] += array1[i - 1];
  for (int i = 1; i < 200005; i++) {
    arr[i] = array1[i];
    int temp = i, count = 0;
    while (temp % 2 == 0) {
      temp /= 2;
      count++;
    }
    if (i != temp) {
      arr[i] = 0;
      arr[temp] += array1[i];
      arr[2] += count * array1[i];
    }
  }
  arr[2] -= num;
  for (int i = 1; i < 200005; i++) ans = (ans * modpow(i, arr[i], m)) % m;
  cout << ans << "\n";
  return 0;
}
