M=10**9+7 t,a,b,c,d,e=ARGF.gets_to_end.split.map(&.to_i) w=[a.abs,b.abs,c.abs].max x=[1_i64]+[0_i64]*200001 t.times{|i| y=[0_i64]*200002 (-w*-~i..w*-~i).map{|j| y[j]=(x[j-a]+x[j+a]+x[j-b]+x[j+b]+x[j-c]+x[j+c])%M } x=y } p x[d..e].sum%M