영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
Consider an n × n grid whose top-left square is (1,1) and bottom-right square is (n,n).
Your task is to move from the top-left square to the bottom-right square. On each step you may move one square right or down. In addition, there are m traps in the grid. You cannot move to a square with a trap.
What is the total number of possible paths?
Input
The first input line contains two integers n and m: the size of the grid and the number of traps.
After this, there are m lines describing the traps. Each such line contains two integers y and x: the location of a trap.
You can assume that there are no traps in the top-left and bottom-right square. You can also assume that each square has at most one trap.
Output
Print the number of paths modulo 10^9+7.
Constraints
- 1 ≤ n ≤ 10^6
- 1 ≤ m ≤ 1000
- 1 ≤ y,x ≤ n
예제
예제 1
3 1 2 2
2