#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a;
int n, m, kq;
void nhap() {
  cin >> n;
  int x;
  for (int i = 1; i <= 2 * n; i++) {
    scanf("%d", &x);
    a.push_back(make_pair(x, (i - 1) % n + 1));
  }
  cin >> m;
}
void cbi() {
  sort(a.begin(), a.end());
  a.push_back(make_pair(1000000010, 1000000010));
  kq = 1;
}
int tinh(int d, int c, int k) {
  int x, y = k;
  for (int i = 2; i <= d; i++) {
    x = i;
    while (c && x % 2 == 0) {
      x /= 2;
      c--;
    }
    y = (1ll * y * x) % m;
  }
  return y;
}
void xuli() {
  int j = 0, l = 0;
  for (int i = 1; i < a.size(); i++) {
    if (a[i] == a[i - 1]) l++;
    if (a[i].first != a[i - 1].first) {
      kq = tinh(i - j, l, kq);
      l = 0;
      j = i;
    }
  }
}
void ghikq() { cout << kq; }
int main() {
  nhap();
  cbi();
  xuli();
  ghikq();
  return 0;
}
