时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
SolarPea thinks inversion is beautiful.
For a 01-sequence

with length

and a constant

, SolarPea defines the
rating of

is:
PolarSea has two integer sequences

and

with length
)
. PolarSea likes a 01-sequence

with length

if and only if

.
SolarPea wrote all 01-sequences which have length

and contain

'1's on the paper. PolarSea saw it and crossed out all sequences that he doesn't like. Now you're given

, please calculate the sum of the
ratings of the remaining sequences on the paper.
Since the answer could be very large, you should output it modulo

(a prime number).
It is guaranteed that
is generated randomly.
输入描述:
The first line contains four non-negative integers 
.
The next

lines, each line contains two non-negative intergers

and
)
.
It is guaranteed that all

are pairwise different.
输出描述:
Output the answer modulo
.
示例3
输入
复制
1004535809 115194 2 21658
822 1
1064 0