#include <bits/stdc++.h>
int IntMaxVal = (int)1e20;
long long LongMaxVal = (long long)1e20;
using namespace std;
long long getCombs(int singles, int pairs, int mod) {
  long long res = 1;
  for (int i = 1; i < singles + 1; ++i) {
    res *= i;
    res %= mod;
  }
  long long places = singles + 1;
  for (int i = 1; i < pairs + 1; ++i) {
    long long positions = places * (places - 1) / 2 + places;
    positions %= mod;
    res *= positions;
    res %= mod;
    places += 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  ;
  vector<pair<int, int> > ps;
  for (int j = 1; j < 2 + 1; ++j)
    for (int i = 1; i < n + 1; ++i) {
      int a;
      cin >> a;
      ;
      ps.push_back(make_pair(a, i));
    }
  sort(ps.begin(), ps.end());
  int m;
  cin >> m;
  ;
  long long res = 1;
  for (int l = 0; l < 2 * n - 1 + 1; ++l) {
    int r = l;
    while (r + 1 < 2 * n && ps[r + 1].first == ps[r].first) r++;
    int pairs = 0;
    for (int i = l + 1; i < r + 1; ++i)
      if (ps[i].second == ps[i - 1].second) pairs++;
    int singles = r + 1 - l - 2 * pairs;
    res *= getCombs(singles, pairs, m);
    res %= m;
    l = r;
  }
  cout << res;
}
