#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); 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 l(M), r(M); for (int i = 0; i < M; i++){ cin >> l[i] >> r[i]; } vector x(N, 0); for (int i = 0; i < M; i++){ for (int j = l[i]; j < r[i]; j++){ x[j] += a[j - l[i]]; } } for (int i = 0; i < N; i++){ cout << x[i] % MOD << endl; } }