#include <bits/stdc++.h>
using namespace std;
int n;
map<int, vector<int> > w;
long long go(int n, int m, int mod) {
  long long res = 1;
  for (int i = 2; i <= n; i++) {
    int t = i;
    while (m && (t % 2 == 0)) {
      t /= 2;
      m--;
    }
    res *= t;
    res %= mod;
  }
  return res;
}
int main() {
  cin >> n;
  for (int j = (0); j < (2); j++)
    for (int i = (0); i < (n); i++) {
      int x;
      scanf("%d", &x);
      w[x].push_back(i);
    }
  int m;
  cin >> m;
  long long res = 1;
  for (map<int, vector<int> >::iterator it = w.begin(); it != w.end(); it++) {
    vector<int> temp = it->second;
    sort((temp).begin(), (temp).end());
    vector<int> t2 = temp;
    sort((t2).begin(), (t2).end()),
        (t2).erase(unique((t2).begin(), (t2).end()), (t2).end());
    int num = temp.size() - t2.size();
    res *= go(temp.size(), num, m);
    res %= m;
  }
  cout << res << endl;
  return 0;
}
