#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, a;     vector<pair<int, int> > v;     cin >> n;     for (i = 0; i < n; ++i) {       cin >> a;       v.push_back(make_pair(a, i + 1));     }     for (i = 0; i < n; ++i) {       cin >> a;       v.push_back(make_pair(a, i + 1));     }     long long m;     cin >> m;     m *= 2;     sort(v.begin(), v.end());     long long r = 1;     int c = 0, c1 = 0;     for (i = 1; i < n + n; ++i) {       if (v[i].first == v[i - 1].first) {         ++c;         if (v[i].second == v[i - 1].second) {           ++c1;         } else           c1 = 0;       } else {         c1 = c = 0;       }       r = (r * (c + 1) / (c1 + 1)) % m;       c1 = 0;     }     cout << r % (m / 2);     return 0;   }   int cpp4cf_main() {     freopen( B.cpp ,  r , stdin);     char s[99];     bool f;     while (true) {       cin >> s;       if (cin.eof()) break;       if (strstr(s,  /* )) {         cin >> s;         if (strstr(s,  Test )) {           cin >> s;           if (strstr(s,  on )) {             cout <<  Output:  ;             cpp4cf_main();             cout <<   nAnswer:  ;             f = false;             while (true) {               cin >> s;               if (strstr(s,  */ )) break;               if (strstr(s,  // )) {                 if (f)                   cout << endl;                 else                   f = true;               } else                 cout << s <<    ;             }             cout <<   n n ;           }         }       }     }     return 0;   }   