233
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 100050 #define mod 1000000007 using namespace std; long long n,m,k,sum[maxn],cnt=0; struct pnt { long long x,y; }p[maxn]; bool cmp(pnt x,pnt y) { if (x.x==y.x) return x.y<y.y; return x.x<y.x; } long long f_pow(long long a,long long b) { a%=mod;b%=mod; long long ans=1,base=a; if (b==0) return 1; while (b) { if (b&1) ans=(ans*base)%mod; base=(base*base)%mod; b>>=1; } return ans%mod; } int main() { scanf("%lld%lld%lld",&n,&m,&k); for (long long i=1;i<=k;i++) scanf("%lld%lld",&p[i].x,&p[i].y); sort(p+1,p+k+1,cmp); for (long long i=1;i<=k;i++) { if ((p[i].x==p[i-1].x) && (p[i].y==p[i-1].y)) continue; if (p[i].x!=p[i-1].x) cnt++; sum[cnt]=(sum[cnt]+p[i].y)%mod; } long long ans=1; for (long long i=1;i<=cnt;i++) ans=(ans*sum[i])%mod; printf("%lld\n",(ans*f_pow(n*(n+1)/2,m-cnt))%mod); return 0; }