local mod = 1000000007 local function badd(x, y) return (x + y) % mod end local dp1, dp2 = {}, {} local offset = 10001 local lim = 20001 for i = 1, lim do dp1[i] = 0 end dp1[offset] = 1 local n = io.read("*n") local a, b, c = io.read("*n", "*n", "*n") if a < 0 then a = -a end if b < 0 then b = -b end if c < 0 then c = -c end local d, e = io.read("*n", "*n") for i = 1, n do local src = i % 2 == 1 and dp1 or dp2 local dst = i % 2 == 1 and dp2 or dp1 for j = 1, lim do dst[j] = 0 end for j = a + 1, lim do dst[j - a] = dst[j - a] + src[j] end for j = 1, lim - a do dst[j + a] = dst[j + a] + src[j] end for j = b + 1, lim do dst[j - b] = dst[j - b] + src[j] end for j = 1, lim - b do dst[j + b] = dst[j + b] + src[j] end for j = c + 1, lim do dst[j - c] = dst[j - c] + src[j] end for j = 1, lim - c do dst[j + c] = dst[j + c] + src[j] end for j = 1, lim do dst[j] = dst[j] % mod end end local ret = 0 local tbl = n % 2 == 1 and dp2 or dp1 for i = offset + d, offset + e do ret = badd(ret, tbl[i]) end print(ret)