#include <bits/stdc++.h>
using namespace std;
int N, mod;
pair<int, int> a[200005];
int main() {
  cin >> N;
  for (int i = 0; i < N + N; ++i) {
    cin >> a[i].first;
    a[i].second = i % N;
  }
  cin >> mod;
  N += N;
  sort(a, a + N);
  long long res = 1;
  for (int i = 0, j = 1; i < N; i = j++) {
    while (j < N && a[i].first == a[j].first) ++j;
    int cnt = j - i;
    for (int z = i; z < j; ++z) {
      if (z + 1 < j && a[z].second == a[z + 1].second) {
        int add = (1ll * cnt * (cnt - 1) / 2) % mod;
        (res *= add) %= mod;
        ++z, --cnt;
      } else
        (res *= cnt) %= mod;
      --cnt;
    }
  }
  cout << res << "\n";
  return 0;
}
