void main(){ import std.stdio, std.string, std.conv, std.algorithm; int t; rd(t); int a, b, c, d, e; rd(a, b, c, d, e); auto dir=[a, -a, b, -b, c, -c]; const mod=1_000_000_000+7; auto rec=new int[](30000); auto ofse=rec.length/2; rec[0+ofse]=1; for(auto i=1; i<=t; i++){ auto tmp=new int[](rec.length); for(auto j=0; j<30000; j++)if(rec[j]>0){ foreach(k; dir) assert(0<=j+k && j+k<30000), (tmp[j+k]+=rec[j])%=mod; } swap(rec, tmp); } int tot=0; for(auto j=d+ofse; j<=e+ofse; j++) (tot+=rec[j])%=mod; writeln(tot); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } } void wr(T...)(T x){ import std.stdio; foreach(e; x) stderr.write(e, " "); stderr.writeln; }