#include <bits/stdc++.h>
using namespace std;
const int MAXN = 205000;
int n, x, mod, cur, len;
vector<pair<int, int> > v;
vector<int> p, pr;
int lp[MAXN * 2];
int d[1000000];
long long res = 1;
void calcp(int len) {
  for (int i = 2; i <= len; i++) {
    int t = i;
    while (t > 1) {
      d[lp[t]]++;
      t /= lp[t];
    }
  }
  for (int i = 0; i < (int)p.size(); i++) {
    int t = p[i];
    while (t > 1) {
      d[lp[t]]--;
      t /= lp[t];
    }
  }
  p.clear();
}
void sieve() {
  for (int i = 2; i <= MAXN; i++) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i]; j++)
      if ((long long)pr[j] * i <= MAXN)
        lp[pr[j] * i] = pr[j];
      else
        break;
  }
}
long long binpow(long long a, int x) {
  long long res = 1;
  while (x) {
    if (x & 1) {
      res = (res * a) % mod;
      x--;
    } else {
      a = (a * a) % mod;
      x /= 2;
    }
  }
  return res;
}
int main() {
  sieve();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    v.push_back(make_pair(x, i));
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    v.push_back(make_pair(x, i));
  }
  scanf("%d", &mod);
  sort(v.begin(), v.end());
  cur = 1;
  len = 1;
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      if (v[i].first != v[i - 1].first) {
        p.push_back(cur);
        calcp(len);
        len = 1;
        cur = 1;
      } else if (v[i].second != v[i - 1].second) {
        p.push_back(cur);
        cur = 1;
        len++;
      } else {
        cur++;
        len++;
      }
    }
  }
  p.push_back(cur);
  calcp(len);
  for (int i = 2; i <= MAXN; i++)
    if (d[i] > 0) {
      res = (res * binpow(i, d[i])) % mod;
    }
  res %= mod;
  cout << res;
  return 0;
}
