import std; const MOD = 10^^9 + 7; long calc(int[] v, int[] r, int a, int b) { const N = 110000; // dp1[i] = 電圧の和が i となる組み合わせの数 auto dp1 = new long[N]; // dp2[i] = 抵抗の和が i となる組み合わせの数 auto dp2 = new long[N]; dp1[0] = dp2[0] = 1; foreach (i; 0..v.length) { for (int j = N-1; j >= v[i]; j--) { dp1[j] += dp1[j - v[i]]; dp1[j] %= MOD; } } foreach (i; 0..r.length) { for (int j = N-1; j >= r[i]; j--) { dp2[j] += dp2[j - r[i]]; dp2[j] %= MOD; } } auto acc = new long[N + 1]; foreach (i; 0..N) acc[i+1] = (acc[i] + dp1[i]) % MOD; long ans = 0; foreach (i; 1..N) { auto lo = min(N, cast(long)a * i); auto hi = min(N, cast(long)b * i + 1); auto x = (acc[hi] - acc[lo] + MOD) % MOD; ans = (ans + dp2[i] * x) % MOD; } return ans; } void main() { int n, m; scan(n, m); auto v = readints; auto r = readints; int a, b; scan(a, b); writeln(calc(v, r, a, b)); } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int;