#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int nax = 2e6 + 7;
long long n, x, l, r, db, m;
long long temp[nax];
vector<pair<long long, long long> > v;
long long calculate(long long n, long long db) {
  long long r = 1;
  for (int i = 1; i <= n; i++) {
    temp[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    while (db > 0 && temp[i] % 2 == 0) {
      db--;
      temp[i] /= 2;
    }
  }
  for (int i = 1; i <= n; i++) {
    r = (r * temp[i]) % m;
  }
  return r;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    v.push_back({x, i});
  }
  for (int i = 1; i <= n; i++) {
    cin >> x;
    v.push_back({x, i});
  }
  sort(v.begin(), v.end());
  cin >> m;
  l = 1, r = 1, db = 0;
  for (int i = 1; i < v.size(); i++) {
    if (v[i].first != v[i - 1].first) {
      r = r * calculate(l, db) % m;
      l = 1;
      db = 0;
    } else {
      l++;
      if (v[i].second == v[i - 1].second) db++;
    }
  }
  r = r * calculate(l, db) % m;
  cout << r << endl;
  return 0;
}
