#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n;
map<int, int> S, F;
map<pair<int, int>, int> M1;
long long m, f[3][maxn + maxn], ans = 1;
int main() {
  int key;
  cin >> n;
  for (int t = 0, _b = 1; t <= _b; ++t)
    for (int i = 1, _b = n; i <= _b; ++i) {
      cin >> key;
      M1[pair<int, int>(key, i)]++;
    }
  cin >> m;
  for (int i = 0, _b = n * 2; i <= _b; ++i) {
    f[1][i] = f[2][i] = i + 1;
    if (i > 0) {
      f[2][i] += f[2][i - 1];
      if (f[2][i] >= m) f[2][i] -= m;
    }
  }
  for (typeof(M1.begin()) k = M1.begin(); k != M1.end(); ++k) {
    int s = S[k->first.first];
    ans = ans * f[k->second][s] % m;
    S[k->first.first] += k->second;
  }
  cout << ans << endl;
  return 0;
}
