#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include using namespace std; const long long MOD = 1000000007; int main(){ int K, N, M; cin >> K >> N >> M; vector a(N + 1, 0); for (int i = 0; i < K; i++){ cin >> a[i]; } vector c(K); for (int i = 0; i < K; i++){ cin >> c[i]; } for (int i = K; i <= N; i++){ for (int j = 0; j < K; j++){ a[i] += a[i - j - 1] * c[j] % MOD; a[i] %= MOD; } } vector b(K); for (int i = 0; i < K; i++){ b[i] = a[i]; for (int j = 0; j < i; j++){ b[i] -= a[i - j - 1] * c[j] % MOD; b[i] += MOD; } b[i] %= MOD; } vector l(M), r(M); for (int i = 0; i < M; i++){ cin >> l[i] >> r[i]; } vector x(N, 0); vector y(N + K, 0); for (int i = 0; i < M; i++){ if (r[i] <= l[i] + max(K * K, 100)){ for (int j = l[i]; j < r[i]; j++){ x[j] += a[j - l[i]]; x[j] %= MOD; } } else { for (int j = l[i]; j < l[i] + K; j++){ y[j] += b[j - l[i]]; } vector sub(K, 0); sub[0] = a[r[i] - l[i]]; for (int j = 1; j < K; j++){ for (int k = j; k < K; k++){ sub[j] += a[r[i] - l[i] - 1 + j - k] * c[k]; sub[j] %= MOD; } } for (int j = r[i]; j < r[i] + K; j++){ y[j] += MOD - sub[j - r[i]]; } } } for (int i = 0; i < N + K; i++){ y[i] %= MOD; } for (int i = 0; i < N + K; i++){ for (int j = 0; j < min(K, i); j++){ y[i] += y[i - j - 1] * c[j] % MOD; y[i] %= MOD; } } for (int i = 0; i < N; i++){ cout << (x[i] + y[i]) % MOD << endl; } }