#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 29;
int a[100010];
map<int, int> mp;
int e[100010][2];
int main() {
  int n, x, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    mp[x]++;
    e[i + 1][0] = x;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    mp[x]++;
    e[i + 1][1] = x;
  }
  scanf("%d", &m);
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    if (e[i][0] == e[i][1]) {
      int t = mp[e[i][0]];
      mp[e[i][0]] -= 2;
      ans *= ((long long)t * (t - 1) / 2) % m;
    } else {
      int t = mp[e[i][0]];
      mp[e[i][0]]--;
      ans *= t;
      ans %= m;
      t = mp[e[i][1]];
      mp[e[i][1]]--;
      ans *= t;
    }
    ans %= m;
  }
  printf("%I64d\n", ans);
}
