Problem:
Score : 100 points

Problem Statement

There is a grid with H horizontal rows and W vertical columns.
Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.

In the grid, N Squares (r_1, c_1), (r_2, c_2), \ldots, (r_N, c_N) are wall squares, and the others are all empty squares.
It is guaranteed that Squares (1, 1) and (H, W) are empty squares.

Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square.

Find the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.

Constraints

All values in input are integers.

2 \leq H, W \leq 10^5

1 \leq N \leq 3000

1 \leq r_i \leq H

1 \leq c_i \leq W

Squares (r_i, c_i) are all distinct.

Squares (1, 1) and (H, W) are empty squares.

Input

Input is given from Standard Input in the following format:

H W N
r_1 c_1
r_2 c_2
:
r_N c_N

Output

Print the number of Taro's paths from Square (1, 1) to (H, W), modulo 10^9 + 7.

Sample Input 1

3 4 2
2 2
1 4

Sample Output 1

3

There are three paths as follows:

Sample Input 2

5 2 2
2 1
4 2

Sample Output 2

0

There may be no paths.

Sample Input 3

5 5 4
3 1
3 5
1 3
5 3

Sample Output 3

24

Sample Input 4

100000 100000 1
50000 50000

Sample Output 4

123445622

Be sure to print the count modulo 10^9 + 7.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define ld long double
    #define ss(x) scanf("%s",&x)
    #define sc(x) scanf("%c",&x)
    #define sd(x) scanf("%Lf",&x)
    #define si(x) scanf("%lld",&x)
    #define ps(x) printf("%s\n",x)
    #define pc(x) printf("%c\n",x)
    #define pd(x) printf("%Lf\n",x)
    #define pi(x) printf("%lld\n",x)
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//


            
    int F[MAX],inF[MAX];
    int mul(int a,int b)
    {
        return ((a%MOD)*(b%MOD))%MOD;
    }
    int add(int a,int b)
    {
        return ((a%MOD)+(b%MOD))%MOD;
    }
    int power(int a,int b)
    {
        int res = 1;
        while(b>0)
        {
            if(b&1)
            {
                res = mul(res,a);
            }
            b = b/2;
            a = mul(a,a);
        }
        return res;
    }
    int sub(int a,int b)
    {
        return ((a%MOD)-(b%MOD)+MOD)%MOD;
    }
    int divi(int a,int b)
    {
        return mul(a,power(b,MOD-2));
    }
    
    void fac(int n)
    {
        F[0]=1;
        fo(i,1,n+1)
        F[i]=mul(F[i-1],i);
    }
    
    void invf(int n)
    {
        inF[0]=1;
        fo(i,1,n+1)
        inF[i]=mul(inF[i-1],power(i,MOD-2));
    
    }
    
    void init()
    {
        F[0]=1;
        fo(i,1,MAX)
        F[i]=mul(i,F[i-1]);
    
        inF[MAX-1]=power(F[MAX-1],MOD-2);
        rfo(i,MAX-1,1)
        inF[i-1]=mul(i,inF[i]);
    }
    
    
    int ncr(int n,int r)
    {
        if(n<r||r<0)return 0;
    
        return mul(F[n],mul(inF[r],inF[n-r]));
    }
    
    bool cmp(const pi a,const pi b)
    {
        return (a.F+a.S)<(b.F+b.S);
    }
    int gbg(int a,int b)
    {
        return ncr(a+b,b);
    }

    int dpd[MAX];
    int temp,h,w,x,y;
    vector<pi> v;

    void solve()
    {
        init();
        cin>>w>>h>>n;
        fo(i,0,n)
        {
            cin>>x>>y;
            v.pb({x,y});
        }
        sort(all(v),cmp);       
        v.pb({w,h});

        temp=0;
        fo(i,0,n+1)
        {
            temp=gbg(v[i].F-1,v[i].S-1);
            fo(j,0,i)
            if(v[j].F<=v[i].F && v[j].S<=v[i].S)
            {
                temp=sub(temp,mul(dpd[j],gbg(-v[j].F+v[i].F,-v[j].S+v[i].S)));
            }
            dpd[i]=temp;
        }

        cout<<temp<<endl;

    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }