#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i) cin >> b[i];
  map<long long, vector<long long> > mp;
  long long m;
  cin >> m;
  for (long long i = 0; i < n; ++i) {
    mp[a[i]].push_back(i + 1);
    mp[b[i]].push_back(i + 1);
  }
  long long ans = 1;
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    long long den = 0;
    long long num = it->second.size();
    sort(it->second.begin(), it->second.end());
    for (long long i = 1; i < (it->second.size()); ++i) {
      if ((it->second[i]) == (it->second[i - 1])) den++;
    }
    long long nn = 1;
    for (long long i = num; i > 0; --i) {
      if (i & 1 || den == 0)
        nn *= i;
      else {
        nn *= (i / 2);
        den--;
      }
      if (nn > m) nn %= m;
    }
    ans *= nn;
    if (ans > m) ans %= m;
  }
  cout << ans % m;
  return 0;
}
