n,m=map(x->parse(Int,x),split(readline()))
s=map(x->parse(Int,x),split(readline()))
t=map(x->parse(Int,x),split(readline()))
dp=zeros(Int,m+1)
sum=ones(Int,m+1)
mod=10^9+7
for i=1:n
	for j=1:m
		dp[j+1]=0
	end
end
println(sum[m+1]%mod)
