#include #define rep(i,n) for (int i = 0; i < (n); ++i) #define chmax(a, b) a = max(a, b); #define chmin(a, b) a = min(a, b); using namespace std; using ll = long long; using P = pair; using VI = vector; using VVI = vector; #define MOD 1000000007 //#define MOD 998244353 struct mint { int i; mint() : i(0) {} mint(int x) { i = int(x % MOD); if (i < 0) i += MOD; } template mint(T x) { i = int(x % MOD); if (i < 0) i += MOD; } mint operator+(const mint x) const {return i + x.i;} mint operator-(const mint x) const {return i - x.i;} mint operator*(const mint x) const {return (long long)i * x.i;} mint operator/(const mint x) const {return (long long)i * x.pow(MOD - 2).i;} mint inv() {return pow(MOD - 2);} template mint pow(T p) const { long long r = 1; long long t = i; for(; p > 0; p >>= 1) { if (p & 1) r = r * t % MOD; t = t * t % MOD; } return r; } template static mint pow(T1 a, T2 b) { long long r = 1; long long t = (long long)(a % MOD); for(; b > 0; b >>= 1) { if (b & 1) r = r * t % MOD; t = t * t % MOD; } return r; } mint& operator+=(const mint x) { i = (i + x.i) % MOD; return *this; } mint& operator-=(const mint x) { i = i - x.i; if (i < 0) i += MOD; return *this; } mint& operator*=(const mint x) { i = (int)((long long)i * x.i % MOD); return *this; } mint& operator/=(const mint x) { i = (long long)i * x.pow(MOD - 2).i % MOD; return *this; } }; std::ostream& operator<<(std::ostream& os, const mint& m) { return os << m.i; } int main() { int k, n, m; cin >> k >> n >> m; vector a(n); rep(i, k) { int ai; cin >> ai; a[i] = ai; } vector c(k); rep(i, k) { int ci; cin >> ci; c[i] = ci; } for(int i = k; i < n; i++) { rep(j, k) a[i] += c[j] * a[i-1-j]; } vector> d(n+1, vector(k)); vector ans(n); rep(_, m) { int l, r; cin >> l >> r; rep(i, k) { int j = l + i; if (j == r) break; ans[j] += a[i]; } l += k; if (l < r) { rep(i, k) d[l][i] += a[i]; rep(i, k) d[r][i] -= a[r-l+i]; } } vector now(k); rep(i, n) { rep(j, k) now[j] += d[i][j]; mint na; rep(j, k) na += c[j] * now[k-1-j]; now.erase(now.begin()); now.push_back(na); ans[i] += na; } rep(i, n) cout << ans[i] << endl; }