Post Office

All submissions for this problem are available.
It's the 1st of the month again, which means it's time for Dave to pay his bills.
Dave needs to go to the post office to mail his rent cheque, and wants to take the
shortest route possible. Dave wonders how many different shortest routes he can take.
Dave lives at the southwest corner of town (0,0) and the post office is at the northeast corner of town (W,H).
It takes Dave exactly one minute to move from (x, y) to (x, y+1), (x, y1), (x+1, y) or (x1, y).
Dave cannot move further south or west than his house, nor can he move further north or east than the post office
(that is, Dave's x coordinate must stay between 0 and W, and his y coordinate must stay between 0 and H at all times).
Additionally, there are N intersections that are being worked on by construction crews,
and Dave must avoid these intersections.
The number of shortest routes may be very large, so print the result modulo 1000000037.
If it is impossible for Dave to reach the post office, the answer is 0.
Input:
Input begins with an integer T, the number of test cases.
Each test case begins with 3 integers W, H, N.
N lines follow, each containing 2 integers (x_{i}, y_{i}), the coordinates of an intersection being worked on by a construction crew.
Intersections are guaranteed to be unique, and neither (0,0) nor (W,H) will be under construction.
A blank line separates each test case.
Output:
For each test case, output a line containing the number of shortest paths to the post office, modulo 1000000037.
Sample input:
3 2 2 1 1 1 1 1 2 0 1 1 0 7 1 2 1 0 4 1
Sample output:
2 0 6
Constraints
1<=T<=30
1<=W,H<=10^{7}
0<=x_{i}<=W
0<=y_{i}<=H
0<=N<=max(100,min(W,H,1000))
Author:  pieguy 
Tester:  anshuman_singh 
Editorial  http://discuss.codechef.com/problems/POST 
Tags  hard, oct10, pieguy 
Date Added:  7072010 
Time Limit:  0.88 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 