Codeforces Round 167 (Div. 1)
B
Dima and Two Sequences
Codeforces
未评级
原题
← AC →
翻译中…

Little Dima has two sequences of points with integer coordinates: sequence $(*a*_{1}, 1), (*a*_{2}, 2), ..., (*a*_{*n*}, *n*)$ and sequence $(*b*_{1}, 1), (*b*_{2}, 2), ..., (*b*_{*n*}, *n*)$.

翻译中…

Now Dima wants to count the number of distinct sequences of points of length $2·*n*$ that can be assembled from these sequences, such that the $*x*$-coordinates of points in the assembled sequence will not decrease. Help him with that. Note that each element of the initial sequences should be used exactly once in the assembled sequence.

翻译中…

Dima considers two assembled sequences $(*p*_{1}, *q*_{1}), (*p*_{2}, *q*_{2}), ..., (*p*_{2·*n*}, *q*_{2·*n*})$ and $(*x*_{1}, *y*_{1}), (*x*_{2}, *y*_{2}), ..., (*x*_{2·*n*}, *y*_{2·*n*})$ distinct, if there is such $*i*$ $(1 ≤ *i* ≤ 2·*n*)$, that $(*p*_{*i*}, *q*_{*i*}) ≠ (*x*_{*i*}, *y*_{*i*})$.

翻译中…

As the answer can be rather large, print the remainder from dividing the answer by number $*m*$.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ $(1 ≤ *n* ≤ 10^{5})$. The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ $(1 ≤ *a*_{*i*} ≤ 10^{9})$. The third line contains $*n*$ integers $*b*_{1}, *b*_{2}, ..., *b*_{*n*}$ $(1 ≤ *b*_{*i*} ≤ 10^{9})$. The numbers in the lines are separated by spaces.

翻译中…

The last line contains integer $*m*$ $(2 ≤ *m* ≤ 10^{9} + 7)$.

翻译中…

Output

翻译中…

In the single line print the remainder after dividing the answer to the problem by number $*m*$.

翻译中…

Note

翻译中…

In the first sample you can get only one sequence: $(1, 1), (2, 1)$.

翻译中…

In the second sample you can get such sequences : $(1, 1), (2, 2), (2, 1), (3, 2)$; $(1, 1), (2, 1), (2, 2), (3, 2)$. Thus, the answer is $2$.

翻译中…

样例

Input #1
1
1
2
7
Output #1
1
InputCopy OutputCopy
Input #2
2
1 2
2 3
11
Output #2
2
InputCopy OutputCopy
题目信息
题号
273B
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。