#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define llint long long #define inf 1e18 #define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++) #define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define mod 1000000007 using namespace std; typedef pair P; llint k, n, m; llint a[100005], c[205]; llint l[100005], r[100005]; llint ans[100005]; vector vec[100005], vec2[100005]; llint b[205]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> k >> n >> m; for(int i = 0; i < k; i++) cin >> a[i]; for(int i = 1; i <= k; i++) cin >> c[i]; for(int i = k; i <= n; i++){ llint sum = 0; for(int j = 1; j <= k; j++) sum += c[j] * a[i-j] % mod, sum %= mod; a[i] = sum; } //for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl; for(int i = 1; i <= m; i++){ cin >> l[i] >> r[i]; for(int j = l[i]; j < min(l[i]+k, r[i]); j++) ans[j] += a[j-l[i]], ans[j] %= mod; if(r[i] - l[i] > k){ vec[l[i]+k].push_back(i); vec2[r[i]].push_back(i); } } //for(int i = 0; i < n; i++) cout << ans[i] << " "; cout << endl; for(int i = 1; i <= n; i++){ for(int j = 0; j < k; j++) b[j] += vec[i].size() * a[j] % mod, b[j] %= mod; for(int j = 0; j < vec2[i].size(); j++){ llint R = r[vec2[i][j]], L = l[vec2[i][j]]; for(int l = 0; l < k; l++) b[l] += mod - a[R-L-k+l], b[l] %= mod; } llint sum = 0; for(int j = 1; j <= k; j++) sum += c[j] * b[k-j] % mod, sum %= mod; ans[i] += sum, ans[i] %= mod; b[k] = sum; for(int j = 0; j < k; j++) b[j] = b[j+1]; //for(int j = 0; j < k; j++) cout << b[j] << " "; cout << endl; } for(int i = 0; i < n; i++) cout << ans[i] << "\n"; flush(cout); return 0; }