import sys #input = sys.stdin.readline input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] MOD = pow(10,8) + 7 n = 550000 #MODは自分で入れよう! fac = [-1]*(n+1); fac[0] = 1; fac[1] = 1 #階乗 finv = [-1]*(n+1); finv[0] = 1; finv[1] = 1 #階乗の逆元 inv = [-1]*(n+1); inv[0] = 0; inv[1] = 1 #逆元 for i in range(2,n+1): fac[i] = fac[i-1]*i%MOD inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD finv[i] = finv[i-1]*inv[i]%MOD def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) ret = fac[n] * finv[r] % p ret = ret * finv[n-r] % p return ret def main(): H,W,K = map(int,input().split()) K2 = 1 << K friends = [] for i in range(K): a,b = map(int,input().split()) friends.append((a,b)) popcount = [0]*K2 #maskに含まれるフレンズをすべて訪れるときの場合の数 #maskに含まれないフレンズはどちらでもよい。 delivery = [0]*K2 for mask in range(K2): popcount[mask] = popcount[mask//2] + mask%2 #配達先 site = [(0,0)] for i in range(K): if (mask>>i)&1 == 1: site.append(friends[i]) site.sort() site.append((H,W)) temp = 1 for i in range(len(site)-1): ux,uy = site[i] vx,vy = site[i+1] dx = vx - ux dy = vy - uy temp *= cmb(dx+dy,dx,MOD) temp %= MOD if popcount[mask]%2 == 0: sgn = 1 else: sgn = -1 delivery[mask] = sgn * temp #print(delivery) #この分がなぜこれでよいのか、理解できていないが今日は寝る。 for i in range(K): for mask in range(K2): if (mask >> i)&1 == 1: delivery[mask] += delivery[mask ^ (1<