#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long int LL;
pair<LL,LL> block[1005];
LL ans[1005],fact[200005];
LL powmod(LL b,LL p)
{
if(p==0)
return 1;
LL ans=powmod(b,p/2);
ans=(ans*ans)%MOD;
if(p%2==0)
return ans;
else
{
ans=(ans*b)%MOD;
return ans;
}
}
LL F(LL a,LL b,LL c,LL d)
{
LL x=c-a;
LL y=d-b;
LL res=fact[x+y];
LL deno=(fact[x]*fact[y])%MOD;
res=res*powmod(deno,MOD-2);
res=res%MOD;
return res;
}
int main()
{
// freopen("input.txt","r",stdin);
LL t,m,n,p,x,y;
fact[0]=1;
for(LL i=1;i<=200005;i++)
{
fact[i]=(fact[i-1]*i)%MOD;
}
scanf("%lld",&t);
while(t--)
{
scanf("%lld %lld %lld",&m,&n,&p);
for(int i=0;i<p;i++)
{
scanf("%lld %lld",&x,&y);
block[i]=make_pair(x,y);
}
block[p]=make_pair(m,n);
sort(block,block+p+1);
for(int i=0;i<=p;i++)
{
ans[i]=F(1,1,block[i].first,block[i].second);
}
for(int i=0;i<p;i++)
{
for(int j=i+1;j<p+1;j++)
{
if((block[j].first<block[i].first)||(block[j].second<block[i].second))
continue;
ans[j]=(ans[j]-(ans[i]*F(block[i].first,block[i].second,block[j].first,block[j].second))%MOD+MOD)%MOD;
}
}
if(ans[p]<0)
ans[p]+=MOD;
printf("%lld\n",ans[p]);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgTU9EIDEwMDAwMDAwMDcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGludCBMTDsKcGFpcjxMTCxMTD4gYmxvY2tbMTAwNV07CkxMIGFuc1sxMDA1XSxmYWN0WzIwMDAwNV07CgpMTCBwb3dtb2QoTEwgYixMTCBwKQp7CiAgICBpZihwPT0wKQogICAgICAgIHJldHVybiAxOwogICAgTEwgYW5zPXBvd21vZChiLHAvMik7CiAgICBhbnM9KGFucyphbnMpJU1PRDsKICAgIGlmKHAlMj09MCkKICAgICAgICByZXR1cm4gYW5zOwogICAgZWxzZQogICAgewogICAgICAgIGFucz0oYW5zKmIpJU1PRDsKICAgICAgICByZXR1cm4gYW5zOwogICAgfQp9CgpMTCBGKExMIGEsTEwgYixMTCBjLExMIGQpCnsKICAgIExMIHg9Yy1hOwogICAgTEwgeT1kLWI7CiAgICBMTCByZXM9ZmFjdFt4K3ldOwogICAgTEwgZGVubz0oZmFjdFt4XSpmYWN0W3ldKSVNT0Q7CiAgICByZXM9cmVzKnBvd21vZChkZW5vLE1PRC0yKTsKICAgIHJlcz1yZXMlTU9EOwogICAgcmV0dXJuIHJlczsKfQoKaW50IG1haW4oKQp7CiAgIC8vIGZyZW9wZW4oImlucHV0LnR4dCIsInIiLHN0ZGluKTsKICAgIExMIHQsbSxuLHAseCx5OwogICAgZmFjdFswXT0xOwogICAgZm9yKExMIGk9MTtpPD0yMDAwMDU7aSsrKQogICAgewogICAgICAgIGZhY3RbaV09KGZhY3RbaS0xXSppKSVNT0Q7CiAgICB9CgogICAgc2NhbmYoIiVsbGQiLCZ0KTsKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgICAgICBzY2FuZigiJWxsZCAlbGxkICVsbGQiLCZtLCZuLCZwKTsKICAgIGZvcihpbnQgaT0wO2k8cDtpKyspCiAgICB7CiAgICAgICAgc2NhbmYoIiVsbGQgJWxsZCIsJngsJnkpOwogICAgICAgIGJsb2NrW2ldPW1ha2VfcGFpcih4LHkpOwogICAgfQogICAgYmxvY2tbcF09bWFrZV9wYWlyKG0sbik7CiAgICBzb3J0KGJsb2NrLGJsb2NrK3ArMSk7CgogICAgZm9yKGludCBpPTA7aTw9cDtpKyspCiAgICB7CiAgICAgICAgYW5zW2ldPUYoMSwxLGJsb2NrW2ldLmZpcnN0LGJsb2NrW2ldLnNlY29uZCk7CiAgICB9CiAgICBmb3IoaW50IGk9MDtpPHA7aSsrKQogICAgewogICAgICAgIGZvcihpbnQgaj1pKzE7ajxwKzE7aisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoKGJsb2NrW2pdLmZpcnN0PGJsb2NrW2ldLmZpcnN0KXx8KGJsb2NrW2pdLnNlY29uZDxibG9ja1tpXS5zZWNvbmQpKQogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIGFuc1tqXT0oYW5zW2pdLShhbnNbaV0qRihibG9ja1tpXS5maXJzdCxibG9ja1tpXS5zZWNvbmQsYmxvY2tbal0uZmlyc3QsYmxvY2tbal0uc2Vjb25kKSklTU9EK01PRCklTU9EOwogICAgICAgIH0KICAgIH0KICAgIGlmKGFuc1twXTwwKQogICAgICAgIGFuc1twXSs9TU9EOwogICAgcHJpbnRmKCIlbGxkXG4iLGFuc1twXSk7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==