# 行列の乗算(mod) def mat_mul(a, b): I, K, J = len(a), len(b), len(b[0]) c = [[0 for j in range(J)] for i in range(I)] for i in range(I): for k in range(K): for j in range(J): c[i][j] += a[i][k] * b[k][j] c[i][j] %= mod return c # 行列の累乗(mod) def mat_pow(a, n): b = [[0 for j in range(len(a))] for i in range(len(a))] for i in range(len(a)): b[i][i] = 1 while n > 0: if n & 1: b = mat_mul(b, a) a = mat_mul(a, a) n >>= 1 return b def segfunc(x,y): return x+y class LazySegTree_RAQ: def __init__(self,init_val,segfunc,ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1<<(n-1).bit_length() self.tree = [ide_ele]*2*self.num self.lazy = [0]*2*self.num for i in range(n): self.tree[self.num+i] = init_val[i] for i in range(self.num-1,0,-1): self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1]) def gindex(self,l,r): l += self.num r += self.num lm = l>>(l&-l).bit_length() rm = r>>(r&-r).bit_length() while r>l: if l<=lm: yield l if r<=rm: yield r r >>= 1 l >>= 1 while l: yield l l >>= 1 def propagates(self,*ids): for i in reversed(ids): v = self.lazy[i] if v==0: continue self.lazy[i] = 0 self.lazy[2*i] += v self.lazy[2*i+1] += v self.tree[2*i] += v self.tree[2*i+1] += v def add(self,l,r,x): ids = self.gindex(l,r) l += self.num r += self.num while l>= 1 l >>= 1 for i in ids: self.tree[i] = self.segfunc(self.tree[2*i], self.tree[2*i+1]) + self.lazy[i] def query(self,l,r): self.propagates(*self.gindex(l,r)) res = self.ide_ele l += self.num r += self.num while l>= 1 r >>= 1 return res mod = 10**9+7 n,m,k = map(int,input().split()) st = [[0]*n for i in range(n)] lr = [[int(i) for i in input().split()] for j in range(m)] for i in range(1,n+1): #使用例 segT = LazySegTree_RAQ([0]*(n+1),segfunc,0) for j in range(m): l,r = lr[j] if l <= i <= r: segT.add(l,r+1,1) for j in range(1,n+1): st[i-1][j-1] = segT.query(j,j+1) #print(st) A = mat_pow(st,k) print(A[0][n-1]%mod)