#include #include using namespace std; using namespace atcoder; #define rep(i, n) for (int i=0; i coef[310]; vector rec(int l, int r) { if (l==r) return coef[l]; int m = (l+r)/2; vector res1 = rec(l, m); vector res2 = rec(m+1, r); vector res = convolution(res1, res2); return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; int A[N], B[N]; rep(i, N) cin >> A[i]; rep(i, N) cin >> B[i]; Cinit(); int offset = 300; rep(i, M) { coef[i].resize(601); rep(j, 601) coef[i][j] = 1ll; } rep(i, M) { for (int j=i; j a(601, 0), b(601, 0); rep(k, A[j]+1) a[k+offset] = C(A[j], k)%MOD; rep(k, B[j]+1) b[offset-k] = C(B[j], k)%MOD; vector conv = convolution(a, b); for (int k=0; k<601; k++) { coef[i][k] *= conv[k+offset]; coef[i][k] %= MOD; } } } vector res = rec(0, M-1); cout << res[M*offset] << endl; }