import std; const MOD = 10^^9 + 7; int calc(int[] v, int[] r, int a, int b) { const N = 110000; // dp1[i] = 電圧の和が i となる組み合わせの数 auto dp1 = new int[N]; // dp2[i] = 抵抗の和が i となる組み合わせの数 auto dp2 = new int[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]]; } } foreach (i; 0..r.length) { for (int j = N-1; j >= r[i]; j--) { dp2[j] += dp2[j - r[i]]; } } auto acc = new int[N + 1]; foreach (i; 0..N) acc[i+1] = acc[i] + dp1[i]; int ans = 0; foreach (i; 1..N) { int lo = min(N, a * i); int hi = min(N, b * i + 1); ans = (ans + dp2[i] * (acc[hi] - acc[lo])) % 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;