n,k = map(int, input().split())
p = 10 ** 9 + 7

##逆元計算
N = n  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

fact = [ 0 for i in range(N+1)]
factinv = fact.copy()
inv = fact.copy()


fact[0], fact[1] = 1, 1
factinv[0], factinv[1] = 1, 1
inv[0], inv[1] = 0, 1
cmb_list = fact.copy()
cmb_list_sub1 = fact.copy()

for i in range(2, N + 1):
    fact[i] = (fact[i-1] * i) % p##階乗のリスト
    inv[i] = (-inv[p % i] * (p // i)) % p
    factinv[i] =(factinv[i-1] * inv[i]) % p##階乗の逆数のリスト
    
#nCrの0=< r <=n までの値のリストがほしい場合
for r in range(1,N+1):
    cmb_list[r] = fact[N] * factinv[r] * factinv[N-r] % p

for r in range(1, n):
    cmb_list_sub1[r] =fact[n-1]*factinv[r]*factinv[n-1-r]%p

ans = 0
if k <= n-1:
    for i in range(0,k+1):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p
else:
    for i in range(0,n):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p
print(ans) n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k p = 10 ** 9 + 7 p 10 ** 9 + 7 10 ** 9 10 9 7 N = n N n fact = [1, 1] fact [1, 1] 1 1 factinv = [1, 1] factinv [1, 1] 1 1 inv = [0, 1] inv [0, 1] 0 1 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 fact = [ 0 for i in range(N+1)] fact [ 0 for i in range(N+1)] factinv = fact.copy() factinv fact.copy() fact.copy fact copy inv = fact.copy() inv fact.copy() fact.copy fact copy fact[0], fact[1] = 1, 1 fact[0] fact 0 1 fact[1] fact 1 1 factinv[0], factinv[1] = 1, 1 factinv[0] factinv 0 1 factinv[1] factinv 1 1 inv[0], inv[1] = 0, 1 inv[0] inv 0 0 inv[1] inv 1 1 cmb_list = fact.copy() cmb_list fact.copy() fact.copy fact copy cmb_list_sub1 = fact.copy() cmb_list_sub1 fact.copy() fact.copy fact copy for i in range(2, N + 1):
    fact[i] = (fact[i-1] * i) % p##階乗のリスト
    inv[i] = (-inv[p % i] * (p // i)) % p
    factinv[i] =(factinv[i-1] * inv[i]) % p##階乗の逆数のリスト
    
#nCrの0=< r <=n までの値のリストがほしい場合 i range(2, N + 1) range 2 N + 1 N 1 fact[i] = (fact[i-1] * i) % p fact[i] fact i (fact[i-1] * i) % p fact[i-1] * i fact[i-1] fact i-1 i 1 i p inv[i] = (-inv[p % i] * (p // i)) % p inv[i] inv i (-inv[p % i] * (p // i)) % p -inv[p % i] * (p // i) -inv[p % i] inv[p % i] inv p % i p i p // i p i p factinv[i] =(factinv[i-1] * inv[i]) % p factinv[i] factinv i (factinv[i-1] * inv[i]) % p factinv[i-1] * inv[i] factinv[i-1] factinv i-1 i 1 inv[i] inv i p for r in range(1,N+1):
    cmb_list[r] = fact[N] * factinv[r] * factinv[N-r] % p r range(1,N+1) range 1 N+1 N 1 cmb_list[r] = fact[N] * factinv[r] * factinv[N-r] % p cmb_list[r] cmb_list r fact[N] * factinv[r] * factinv[N-r] % p fact[N] * factinv[r] * factinv[N-r] fact[N] * factinv[r] fact[N] fact N factinv[r] factinv r factinv[N-r] factinv N-r N r p for r in range(1, n):
    cmb_list_sub1[r] =fact[n-1]*factinv[r]*factinv[n-1-r]%p r range(1, n) range 1 n cmb_list_sub1[r] =fact[n-1]*factinv[r]*factinv[n-1-r]%p cmb_list_sub1[r] cmb_list_sub1 r fact[n-1]*factinv[r]*factinv[n-1-r]%p fact[n-1]*factinv[r]*factinv[n-1-r] fact[n-1]*factinv[r] fact[n-1] fact n-1 n 1 factinv[r] factinv r factinv[n-1-r] factinv n-1-r n-1 n 1 r p ans = 0 ans 0 if k <= n-1:
    for i in range(0,k+1):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p
else:
    for i in range(0,n):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p k <= n-1 k n-1 n 1 for i in range(0,k+1):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p i range(0,k+1) range 0 k+1 k 1 ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p ans (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p ans + cmb_list[i] * cmb_list_sub1[n-1-i] ans cmb_list[i] * cmb_list_sub1[n-1-i] cmb_list[i] cmb_list i cmb_list_sub1[n-1-i] cmb_list_sub1 n-1-i n-1 n 1 i p for i in range(0,n):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p i range(0,n) range 0 n ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p ans (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p ans + cmb_list[i] * cmb_list_sub1[n-1-i] ans cmb_list[i] * cmb_list_sub1[n-1-i] cmb_list[i] cmb_list i cmb_list_sub1[n-1-i] cmb_list_sub1 n-1-i n-1 n 1 i p print(ans) print ans cmb_list = fact.copy() fact.copy() cmb_list inv = [0, 1] [0, 1] inv fact = [1, 1] [1, 1] fact fact = [ 0 for i in range(N+1)] [ 0 for i in range(N+1)] fact ans = 0 0 ans ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p ans p = 10 ** 9 + 7 10 ** 9 + 7 p factinv = [1, 1] [1, 1] factinv cmb_list_sub1 = fact.copy() fact.copy() cmb_list_sub1 k = map(int, input().split()) map(int, input().split()) k N = n n N ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p ans factinv = fact.copy() fact.copy() factinv inv = fact.copy() fact.copy() inv n,k = map(int, input().split()) map(int, input().split()) n
n,k = map(int, input().split())
p = 10 ** 9 + 7

##逆元計算
N = n  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

fact = [ 0 for i in range(N+1)]
factinv = fact.copy()
inv = fact.copy()


fact[0], fact[1] = 1, 1
factinv[0], factinv[1] = 1, 1
inv[0], inv[1] = 0, 1
cmb_list = fact.copy()
cmb_list_sub1 = fact.copy()

for i in range(2, N + 1):
    fact[i] = (fact[i-1] * i) % p##階乗のリスト
    inv[i] = (-inv[p % i] * (p // i)) % p
    factinv[i] =(factinv[i-1] * inv[i]) % p##階乗の逆数のリスト
    
#nCrの0=< r <=n までの値のリストがほしい場合
for r in range(1,N+1):
    cmb_list[r] = fact[N] * factinv[r] * factinv[N-r] % p

for r in range(1, n):
    cmb_list_sub1[r] =fact[n-1]*factinv[r]*factinv[n-1-r]%p

ans = 0
if k <= n-1:
    for i in range(0,k+1):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p
else:
    for i in range(0,n):
        ans = (ans + cmb_list[i] * cmb_list_sub1[n-1-i])%p
print(ans)