#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
using namespace std;
using tii = tuple<int, int>;
int main() {
  int n, m;
  scanf("%d", &n);
  map<int, map<int, int>> c;
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    c[a][i]++;
  }
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    c[a][i]++;
  }
  scanf("%d", &m);
  int64_t ans = 1;
  for (auto& kv : c) {
    auto& cc = kv.second;
    if (cc.size() > 1) {
      int total = 0, two = 0;
      for (auto& kv2 : cc) {
        total += kv2.second;
        if (kv2.second == 2) two++;
      }
      for (int i = 1; i <= total; i++) {
        ans *= i;
        if (two > 0 && i % 2 == 0) ans /= 2, two--;
        ans %= m;
      }
    }
  }
  printf("%" PRId64 "\n", ans);
  return 0;
}
