Increasing Arcade Paths

Time limit2sMemory limit128 MB

Summary
Count monotone grid paths from (1,1) to (N,M) grouped by how many arcades they visit, valid only if visited arcade numbers strictly increase.
Level

Hard8 of 10

Topics
Dynamic programming, Combinatorics, Math, Matrix
Solved
No attempts yet

Problem

There is an N * M grid city. The home is at (1, 1), and the destination is at (N, M). The city contains C arcades numbered from 1 to C.

From position (r, c), you may move only to (r + 1, c) or (r, c + 1). In other words, you may move only downward or rightward.

Whenever a path passes through arcades, the visited arcade numbers must be strictly increasing. For example, after visiting arcade 2, you cannot visit arcade 1. Arcade 2 can be visited only if no arcade has been visited before it, or if arcade 1 was visited before it.

For each K = 0, 1, ..., C, count the number of paths from home to the destination that visit exactly K arcades.

Input

The first line contains N M C. N and M are positive integers at most 50, and C is an integer from 0 to 50.

Each of the next C lines gives the position of an arcade, in order from arcade 1 through arcade C. No two arcades occupy the same position. An arcade may be located at (1, 1) or (N, M).

Output

Print one line containing C + 1 integers: the number of paths that visit 0, 1, ..., C arcades, separated by spaces.

Print each count modulo 1,000,007.

Examples4

  1. Example 1

    Input
    3 3 2
    2 2
    3 2
    
    Expected output
    1 3 2
    
  2. Example 2

    Input
    6 4 2
    5 3
    3 2
    
    Expected output
    14 24 0
    
  3. Example 3

    Input
    5 5 3
    1 3
    2 4
    3 5
    
    Expected output
    42 14 10 4
    
  4. Example 4

    Input
    50 50 2
    50 50
    1 1
    
    Expected output
    0 0 0