#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
const int maxm = 2000010;
const int INF = 1e9;
const int mod = 1e9 + 7;
int n, m;
int pa[maxn];
int pb[maxn];
long long extend_gcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0 && b == 0) return -1;
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extend_gcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
long long mod_reverse(long long a, long long c) {
  long long x, y;
  long long d = extend_gcd(a, c, x, y);
  if (d == 1)
    return (x % c + c) % c;
  else
    return -1;
}
struct Point {
  int x;
  int y;
} pp[maxn];
bool cmp(Point P, Point Q) {
  if (P.x == Q.x) return P.y < Q.y;
  return P.x < Q.x;
}
int main() {
  int i, j;
  scanf("%d", &n);
  int num = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &pa[i]);
    pp[num].x = pa[i];
    pp[num].y = i;
    num++;
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", &pb[i]);
    pp[num].x = pb[i];
    pp[num].y = i;
    num++;
  }
  sort(pp, pp + num, cmp);
  scanf("%d", &m);
  long long tt = mod_reverse(2, m);
  if (tt < 0) tt += m;
  long long ans = 1;
  pp[num].x = 0;
  pp[num].y = 0;
  for (i = 0; i < num; i++) {
    long long cnt = 1;
    int c = i;
    int gg = 0;
    while (pp[c].x == pp[c + 1].x) {
      if (pp[c].y == pp[c + 1].y) gg++;
      c++;
    }
    while (pp[i].x == pp[i + 1].x) {
      cnt++;
      ans *= cnt;
      while (!(ans & 1) && gg) {
        ans >>= 1;
        gg--;
      }
      ans %= m;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}
