#include #include #include #define MAXN 6000 #define MAXK 3 using namespace std; long long mod = 10000000019L; long long maze[MAXN][MAXN]; int N, K; inline long long S(int x, int y){ if(x == 0 && y == 0){ return 1;} if(maze[y][x] == -1){ return 0; } if(maze[y][x] > 0){ return maze[y][x]; } long long s = 0; if (x - 1 >= 0){ s += S(x-1, y); //s = (S(x-1, y) + s) % mod; } if (y - 1 >= 0){ s += S(x, y-1); // = (S(x, y-1) + s) % mod; } maze[y][x] = s % mod; return maze[y][x]; } int main() { freopen ("grid.in", "r", stdin); freopen ("grid.out", "w" , stdout); int a, b; scanf("%d %d", &N, &K); maze[0][0] = 1; for(int i = 0; i < K;i++){ scanf("%d %d", &a, &b); maze[b-1][a-1] = -1; } printf("%I64d\n", S(N-1,N-1)); return 0; }