Time limit
2s
Memory limit
128 MB
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.
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).
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.