Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 4 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 15 Sep 2017 My Price 7.00

number of ways

You have a N x M matrix of cells. The cell (i,?j) represents the cell at row i and column j. You can go from one cell (i,?j) only down or right, that is to cells (i?+?1,?j) or (i,?j?+?1).

But K cells are blocked in the matrix(you can’t visit a blocked cell). You are given coordinates of all these cells.

You have to count number of ways to reach cell (N, M) if you begin at cell (1, 1).

Two ways are same if and only if path taken is exactly same in both ways.

Input

First line consists of T, denoting the number of test cases.
Each test case consists of N, M and K in single line. Each of the next K lines contains two space separated integers (xi, yi), denoting the blocked cell’s coordinates.

 

Output

For each test case print the required answer modulo 109+7 in one line.

 

Constraints

  • 1 = T = 10
  • 1 = N, M = 105
  • 0 = K = 103
  • 1 = xi = N
  • 1 = yi = M

 

Example

Input: 2 3 2 0 2 3 1 1 2 Output: 3 1

 

Explanation

Example test case 1.
No cell is blocked.
3 distinct paths are:
(1,1) -> (1,2) -> (2,2) -> (3,2).
(1,1) -> (2,1) -> (2,2) -> (3,2).
(1,1) -> (2,1) -> (3,1) -> (3,2).


Example test case 2.
Only one valid path (1,1) -> (2,1) -> (2,2) -> (2,3).

Answers

(5)
Status NEW Posted 15 Sep 2017 11:09 PM My Price 7.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)