#include <bits/stdc++.h>
using namespace std;
long long int func(long long int a, long long int b, long long int m) {
  long long int ans = 1;
  for (long long int i = 1; i <= a; i++) {
    ans = (ans * i) % m;
    if (ans == 0) ans = m;
    if (ans % 2 == 0 && b > 0) {
      ans = ans / 2;
      b--;
    }
  }
  for (long long int i = 1; i <= b; i++) {
    ans = ans / 2;
  }
  return ans;
}
void solve() {
  long long int n, m, i, ans = 1;
  cin >> n;
  map<long long int, pair<long long int, long long int>> make_pair;
  long long int a[n + 1], b[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (make_pair.count(a[i]) == 0)
      make_pair[a[i]].first = 1;
    else
      make_pair[a[i]].first++;
  }
  for (i = 1; i <= n; i++) {
    cin >> b[i];
    if (make_pair.count(b[i]) == 0) {
      make_pair[b[i]].first = 1;
      continue;
    }
    if (a[i] != b[i]) {
      make_pair[b[i]].first++;
    } else {
      make_pair[b[i]].first++;
      make_pair[b[i]].second++;
    }
  }
  cin >> m;
  for (auto it = make_pair.begin(); it != make_pair.end(); it++) {
    ans = (ans * func((it->second).first, (it->second).second, m)) % m;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
