#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const long long INF = 1e18;   const long double PI = 4 * atan((long double)1);   const int INFTY = 1e7;   template <unsigned int N>   class Field {     inline unsigned int pow(unsigned int a, unsigned int p) {       unsigned int r = 1, e = a;       while (p) {         if (p & 1) {           r = ((unsigned long long)r * e) % N;         }         e = ((unsigned long long)e * e) % N;         p >>= 1;       }       return r;     }     inline unsigned int inv(unsigned int a) { return pow(a, N - 2); }       public:     inline Field(int x = 0) : v(x) {}     inline Field<N> pow(int p) { return (*this) ^ p; }     inline Field<N> operator^(int p) { return {(int)pow(v, (unsigned int)p)}; }     inline Field<N> &operator+=(const Field<N> &o) {       if (v + o.v >= N)         v += o.v - N;       else         v += o.v;       return *this;     }     inline Field<N> &operator-=(const Field<N> &o) {       if (v < o.v)         v -= o.v - N;       else         v -= o.v;       return *this;     }     inline Field<N> &operator*=(const Field<N> &o) {       v = (unsigned long long)v * o.v % N;       return *this;     }     inline Field<N> &operator/=(const Field<N> &o) { return *this *= inv(o.v); }     inline Field<N> operator+(const Field<N> &o) const {       Field<N> r{*this};       return r += o;     }     inline Field<N> operator-(const Field<N> &o) const {       Field<N> r{*this};       return r -= o;     }     inline Field<N> operator*(const Field<N> &o) const {       Field<N> r{*this};       return r *= o;     }     inline Field<N> operator/(const Field<N> &o) const {       Field<N> r{*this};       return r /= o;     }     inline Field<N> operator-() {       if (v)         return {(int)(N - v)};       else         return {0};     };     inline Field<N> &operator++() {       ++v;       if (v == N) v = 0;       return *this;     }     inline Field<N> operator++(int) {       Field<N> r{*this};       ++*this;       return r;     }     inline Field<N> &operator--() {       --v;       if (v == -1) v = N - 1;       return *this;     }     inline Field<N> operator--(int) {       Field<N> r{*this};       --*this;       return r;     }     inline bool operator==(const Field<N> &o) const { return o.v == v; }     inline bool operator!=(const Field<N> &o) const { return o.v != v; }     inline explicit operator unsigned int() const { return v; }     inline static vector<Field<N>> fact(int t) {       vector<Field<N>> F(t + 1, 1);       for (int i = 2; i <= t; ++i) {         F[i] = F[i - 1] * i;       }       return F;     }     inline static vector<Field<N>> invfact(int t) {       vector<Field<N>> F(t + 1, 1);       Field<N> X{1};       for (int i = 2; i <= t; ++i) {         X = X * i;       }       F[t] = 1 / X;       for (int i = t - 1; i >= 2; --i) {         F[i] = F[i + 1] * (i + 1);       }       return F;     }       private:     unsigned int v;   };   template <unsigned int N>   istream &operator>>(std::istream &is, Field<N> &first) {     unsigned int v;     is >> v;     first = v;     return is;   }   template <unsigned int N>   ostream &operator<<(std::ostream &os, const Field<N> &first) {     return os << (unsigned int)first;   }   template <unsigned int N>   Field<N> operator+(int i, const Field<N> &first) {     return Field<N>(i) + first;   }   template <unsigned int N>   Field<N> operator-(int i, const Field<N> &first) {     return Field<N>(i) - first;   }   template <unsigned int N>   Field<N> operator*(int i, const Field<N> &first) {     return Field<N>(i) * first;   }   template <unsigned int N>   Field<N> operator/(int i, const Field<N> &first) {     return Field<N>(i) / first;   }   long long fact[200005];   long long MI[200005];   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long n, m;     cin >> n;     vector<pair<long long, long long>> a(2 * n);     for (int i = 0; i < (2 * n); i++) cin >> a[i].first, a[i].second = i % n;     sort(a.begin(), a.end());     cin >> m;     fact[0] = fact[1] = 1;     for (int i = 2; i <= 200000; ++i) fact[i] = (1ll * fact[i - 1] * i) % m;     MI[0] = 1;     MI[1] = (m + 1) / 2;     for (int i = 2; i <= 200000; ++i) MI[i] = (MI[i - 1] * MI[1]) % m;     int i = 0;     long long ans = 1;     while (i < 2 * n) {       int j = i, c = 0;       while (j < 2 * n && a[i].first == a[j].first) {         if (j > i && a[j].second == a[j - 1].second) {           c++;         }         j++;       }       for (int x = 1; x <= j - i; x++) {         int y = x;         while (y % 2 == 0 && c > 0) {           y /= 2;           c--;         }         ans = (ans * y) % m;       }       i = j;     }     cout << ans << endl;   }