#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T& x, T& y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T& x, T& y, T& z) {
  read(x);
  read(y);
  read(z);
}
inline char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int N = 200010;
int n, m, i, j, k, l, p, x;
pair<int, int> a[N];
int T, cnt[N];
long long ans, tot;
int c[N], d[N];
long long pow(long long a, long long b, long long c) {
  long long ans = 1;
  for (a %= c; b; b >>= 1, a = a * a % c)
    if (b & 1) ans = ans * a % c;
  return ans;
}
int main() {
  read(n);
  for (i = 1; i <= n; i++) read(x), a[i] = make_pair(x, i);
  for (i = 1; i <= n; i++) read(x), a[n + i] = make_pair(x, i);
  read(m);
  n *= 2;
  for (i = 2; i <= n; i++)
    if (!d[i])
      for (j = 2; j <= n / i; j++) d[i * j] = i;
  sort(a + 1, a + 1 + n);
  ans = 1;
  for (i = 1; i <= n; i = j + 1) {
    for (j = i; j <= n && a[j].first == a[i].first; j++)
      ;
    j--;
    T++;
    int tot = 0;
    for (k = i; k <= j; k++) {
      if (cnt[a[k].second] != T)
        cnt[a[k].second] = T;
      else
        tot++;
    }
    for (k = 1; k <= j - i + 1; k++) c[k]++;
    c[2] -= tot;
  }
  for (i = n; i >= 2; i--) {
    if (d[i] == 0)
      ans = ans * pow(i, c[i], m) % m;
    else {
      c[d[i]] += c[i];
      c[i / d[i]] += c[i];
    }
  }
  cout << ans << endl;
  return 0;
}
