#include <bits/stdc++.h>   using namespace std;   long long n, mod;   pair<long long, long long> a[200100];   long long d[200100];   long long first(int t, int k) {     long long res = 1;     for (int i = 1; i <= k; i++) d[i] = i;     for (int j = 2; t;)       if (d[j] % 2)         j += 2;       else         while (d[j] % 2 == 0 && t) {           d[j] /= 2;           t--;         }     for (int i = 1; i <= k; i++) res = (res * d[i]) % mod;     return res;   }   int main() {     cin >> n;     for (int i = 0; i < 2 * n; ++i) {       cin >> a[i].first;       a[i].second = (i % n) + 1;     }     sort(a, a + 2 * n);     cin >> mod;     long long r = 1;     for (int i = 0; i < 2 * n; i++) {       long long k, t = 0;       for (k = i + 1; k < 2 * n && a[k].first == a[i].first; k++)         if (a[k].second == a[k - 1].second) t++;       k--;       r = (r * first(t, k - i + 1)) % mod;       i = k;     }     cout << r;     return 0;   }   