#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #pragma warning(disable:4996) typedef long long ll; typedef unsigned long long ull; #define MIN(a, b) ((a)>(b)? (b): (a)) #define MAX(a, b) ((a)<(b)? (b): (a)) #define LINF 9223300000000000000 #define LINF2 1223300000000000000 #define INF 2140000000 const long long MOD = 1000000007; //const long long MOD = 998244353; using namespace std; ll dp[2][100005]; void calc(int n, const vector& v, vector& v0) { int prev = 0, curr = 1; int i,j; for (i = 0; i <= 100000; i++) { dp[0][i] = dp[1][i] = 0; } dp[0][0] = 1; for (i = 0; i < n; i++) { for (j = 0; j <= 100000; j++) { dp[curr][j] = 0; } for (j = 0; j <= 100000; j++) { if (dp[prev][j]) { dp[curr][j] = (dp[curr][j] + dp[prev][j]) % MOD; int j2 = j + v[i]; dp[curr][j2] = (dp[curr][j2] + dp[prev][j]) % MOD; } } swap(prev, curr); } for (i = 0; i <= 100000; i++) { v0[i] = dp[prev][i]; } return; } void solve() { int n, m; scanf("%d%d", &n, &m); vector v(n), r(m); int i; for (i = 0; i < n; i++) { scanf("%d", &v[i]); } for (i = 0; i < m; i++) { scanf("%d", &r[i]); } int a, b; scanf("%d%d", &a, &b); vector v0(100005); vector v1(100005); calc(n, v, v0); calc(m, r, v1); #if 0 vector sv0(100005); for (i = 0; i <= 100000; i++) { sv0[i + 1] = (sv0[i] + v0[i]) % MOD; } ll ans = 0; for (i = 1; i <= 100000; i++) { int lim0 = a * i, lim1 = MIN(100000, b * i); if (lim0 > 100000) continue; ll tmp0 = (sv0[lim1 + 1] - sv0[lim0] + MOD) % MOD; ll tmp = tmp0 * v1[i] % MOD; ans = (ans + tmp) % MOD; } printf("%lld\n", ans); #endif return; } int main(int argc, char* argv[]) { #if 1 solve(); #else int T; scanf("%d", &T); int t; for(t=0; t