#include using namespace std; #define rep2(i, m, n) for(int i=int(m); i; const int MOD = int(1e9) + 7; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; int main() { ll k, n, m; cin >> k >> n >> m; Vll a(k+n), c(k+1); c[0] = -1; rep(i, k) { cin >> a[i]; (a[i] += MOD) %= MOD; } rep(i, k) { cin >> c[i+1]; (c[i+1] += MOD) %= MOD; } rep2(i, k, n+k) rep2(j, 1, k+1) (a[i] += c[j]*a[i-j]) %= MOD; Vll y(n); rep(_, m) { int l, r; cin >> l >> r; rep(i, k) rep(j, k-i) if (l+i+j < n) (y[l+i+j] -= c[i] * a[j]) %= MOD; rep(i, k) rep(j, k-i) if (r+i+j < n) (y[r+i+j] += c[i] * a[r-l+j]) %= MOD; } Vll x(n+k); rep(i, n) { x[k+i] = y[i]; rep2(j, 1, k+1) (x[k+i] += c[j] * x[k+i-j]) %= MOD; cout << x[k+i] << "\n"; } return 0; }