n,m=map(int,input().split())
mod=10**9+7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = mod
N = 4 * 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
def shikiri(a,b):
    return fact[a+b]*factinv[a]*factinv[b]%mod

ans=0
for i in range(min(n,m+1)):
    ans+=shikiri(n-1-i,i)*cmb(n,i,p)
    #print(ans)
    ans%=mod

if m==1:
    ans-=1
print(ans) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m mod=10**9+7 mod 10**9+7 10**9 10 9 7 def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p cmb if (r < 0) or (n < r):
        return 0
     (r < 0) or (n < r) r < 0 r 0 n < r n r return 0 0 r = min(r, n - r) r min(r, n - r) min r n - r n r return fact[n] * factinv[r] * factinv[n-r] % p 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 n n r r p p p = mod p mod N = 4 * 10 ** 6 + 10 N 4 * 10 ** 6 + 10 4 * 10 ** 6 4 10 ** 6 10 6 10 fact = [1, 1] fact [1, 1] 1 1 factinv = [1, 1] factinv [1, 1] 1 1 inv = [0, 1] inv [0, 1] 0 1 for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
     i range(2, N + 1) range 2 N + 1 N 1 fact.append((fact[-1] * i) % p) fact.append fact append (fact[-1] * i) % p fact[-1] * i fact[-1] fact -1 i p inv.append((-inv[p % i] * (p // i)) % p) inv.append inv append (-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.append((factinv[-1] * inv[-1]) % p) factinv.append factinv append (factinv[-1] * inv[-1]) % p factinv[-1] * inv[-1] factinv[-1] factinv -1 inv[-1] inv -1 p def shikiri(a,b):
    return fact[a+b]*factinv[a]*factinv[b]%mod shikiri return fact[a+b]*factinv[a]*factinv[b]%mod fact[a+b]*factinv[a]*factinv[b]%mod fact[a+b]*factinv[a]*factinv[b] fact[a+b]*factinv[a] fact[a+b] fact a+b a b factinv[a] factinv a factinv[b] factinv b mod a a b b ans=0 ans 0 for i in range(min(n,m+1)):
    ans+=shikiri(n-1-i,i)*cmb(n,i,p)
    #print(ans)
    ans%=mod i range(min(n,m+1)) range min(n,m+1) min n m+1 m 1 ans+=shikiri(n-1-i,i)*cmb(n,i,p) ans shikiri(n-1-i,i)*cmb(n,i,p) shikiri(n-1-i,i) shikiri n-1-i n-1 n 1 i i cmb(n,i,p) cmb n i p ans%=mod ans mod if m==1:
    ans-=1 m==1 m 1 ans-=1 ans 1 print(ans) print ans m=map(int,input().split()) map(int,input().split()) m p = mod mod p N = 4 * 10 ** 6 + 10 4 * 10 ** 6 + 10 N def shikiri(a,b):
    return fact[a+b]*factinv[a]*factinv[b]%mod def shikiri(a,b):
    return fact[a+b]*factinv[a]*factinv[b]%mod shikiri ans+=shikiri(n-1-i,i)*cmb(n,i,p) shikiri(n-1-i,i)*cmb(n,i,p) ans ans%=mod mod ans ans-=1 1 ans def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p cmb factinv = [1, 1] [1, 1] factinv ans=0 0 ans n,m=map(int,input().split()) map(int,input().split()) n mod=10**9+7 10**9+7 mod inv = [0, 1] [0, 1] inv fact = [1, 1] [1, 1] fact
n,m=map(int,input().split())
mod=10**9+7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = mod
N = 4 * 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
def shikiri(a,b):
    return fact[a+b]*factinv[a]*factinv[b]%mod

ans=0
for i in range(min(n,m+1)):
    ans+=shikiri(n-1-i,i)*cmb(n,i,p)
    #print(ans)
    ans%=mod

if m==1:
    ans-=1
print(ans)