There is a row of \(N\) houses labeled \(1 \dots N\) from left to right. You start in house \(1\), and you can move only by teleporting. In order to teleport from house \(X\) to house \(Y\), you must wait at least \(|X-Y|\) units of time (possibly more) before instantaneously teleporting to house \(Y\). It is not allowed to teleport from a house to the same house.
There are \(K\) parties in the houses at various points in time, and you want to attend all of them. The \(i^{th}\) party takes place at house \(x_i\) and at time \(t_i\), and to attend this party, you must reach house \(x_i\) at exactly time \(t_i\). You are allowed to revisit houses, but you are not allowed to wait at a house until a party there begins. There may be multiple parties at a house, although at different times, and there may be multiple parties at a single time, although at different houses.
Define a teleportation sequence as an ordered list of pairs \((a,b)\) indicating the position and time of reaching of a house respectively, ordered in chronological order. The pair \((1,0)\) is the beginning of every teleportation sequence.
How many distinct teleportation sequences are there which allow you to attend all the parties, modulo \(1,000,000,007\) \((10^9 + 7)\)?
Input Format :
The first line of input contains three space-separated integers, \(N, T\) (the time of the last party), and \(K\).
The next \(K\) lines of input each contain two space-separated integers, \(x_i\) and \(t_i\).
Output Format :
Print the number of distinct teleportation sequences which visit all the parties, modulo \(1,000,000,007\) \((10^9 + 7)\).
Constraints :
\(1 \le N,T,K \le 5000\)
\(1 \le x_i \le N\)
\(1 \le t_i \le T\)
There will be at least one party taking place at time \(T\).
It is guaranteed that there are no two indices \(i\) and \(j\), \(i \neq j\), such that \(x_i = x_j\) and \(t_i = t_j\) both hold true.