#include <bits/stdc++.h>
using namespace std;
long double const pi = 3.141592653589793238462;
long long int power(long long int a, long long int b, long long int m) {
  long long int f = 1;
  while (b > 0) {
    if (b & 1) {
      f = f * a;
      f %= m;
    }
    a = a * a;
    a %= m;
    b = b / 2;
  }
  return f;
}
long long int const N = 2e5 + 5;
long long int inc[N];
vector<long long int> pr;
long long int bb[N];
void seive() {
  for (long long int i = 2; i < N; i++) {
    if (bb[i] == 0) {
      pr.push_back(i);
      for (long long int j = i * i; j < N; j += i) bb[j] = 1;
    }
  }
}
map<long long int, long long int> m1;
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m, i, j, l;
  cin >> n;
  seive();
  vector<long long int> a;
  for (i = 0; i < n; i++) {
    cin >> j;
    a.push_back(j);
  }
  for (i = 0; i < n; i++) {
    cin >> j;
    if (a[i] == j) {
      m1[j]++;
    }
    a.push_back(j);
  }
  long long int ans = 1;
  cin >> m;
  sort(a.begin(), a.end());
  for (i = 0; i < a.size(); i++) {
    l = 1;
    j = a[i];
    for (i = i + 1; i < a.size(); i++) {
      if (a[i] != j) break;
      l++;
    }
    for (long long int k = 0; k < pr.size() && pr[k] <= l; k++) {
      long long int x = pr[k];
      while (x <= l) {
        inc[k] = inc[k] + (l / x);
        x = x * pr[k];
      }
    }
    i--;
    long long int x = m1[j];
    inc[0] -= x;
  }
  for (i = 0; i < pr.size(); i++) {
    ans = ans * (power(pr[i], inc[i], m));
    ans = ans % m;
  }
  cout << ans << endl;
  return 0;
}
