Just Jump
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Gromah and LZR have entered the final level. In this level, they need to cross the sea of death to gain the treasures.

The sea of death is of width , and there are  stones inside the sea. Assume that Gromah and LZR are at position initially, that the treasures are at position , and that stones are at position  respectively. So Gromah and LZR can jump on the stones to cross the sea.

Unfortunately, the stones are not stable. To ensure safety, Gromah and LZR should go forward at least positions each time. Formally, if they are at position  currently, they should jump onto the positions not less than . Moreover, they can't be at positions greater than  in any time, which means that the destination of their last jump should be exactly position , or the treasure keepers will see them and come to eat them.

More unfortunately, the Infernos under the sea will attack them  times in total, each attack can be described as a tuple , denoting that the stone at position  will be attacked right after their -th jump, which means their destination of -th jump can't be position .

But fortunately, here comes the farmer(mentioned in problem I but not necessary to care in this problem) and he tells Gromah and LZR all the attack plans, so they can work out some jumping plans according to the information given by the farmer to get to the destination without being attacked.

Please help them determine the number of jumping plans satisfying all the restrictions described above. Since the number may be very large, you should report it modulo .

Two jumping plans are considered different if there exists at least one that their positions after -th jump are different in two plans.

输入描述:

The first line contains three positive integers , denoting the width of the sea, the lower bound of jumping distance, and the number of attacks.

Following  lines each contains two positive integers , denoting an attack .



 attacks are pairwise distinct, where two attacks (t_1, p_1), (t_2, p_2) are considered different if  or  or both.

输出描述:

Print a non-negative integer in one line, denoting the answer modulo .
示例1

输入

复制
5 2 1
1 2

输出

复制
2

说明

There are three plans originally : 0\rightarrow 2 \rightarrow 5, \; 0\rightarrow 3 \rightarrow 5, \; 0\rightarrow 5. But after the first jump, the stone at position 2 will be attacked, so plan 0 \rightarrow 2 \rightarrow 5 should be abandoned and 2 valid plans remain.