#include using namespace std; template< int mod > struct ModInt { int x; constexpr ModInt() : x(0) {} constexpr ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} constexpr ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; } constexpr ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } constexpr ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; } constexpr ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } constexpr ModInt operator-() const { return ModInt(-x); } constexpr ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } constexpr ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } constexpr ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } constexpr ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } constexpr bool operator==(const ModInt &p) const { return x == p.x; } constexpr bool operator!=(const ModInt &p) const { return x != p.x; } constexpr bool operator<(const ModInt &p) const { return x < p.x; } constexpr ModInt& operator++() { (*this).x+=1; return (*this); } constexpr ModInt& operator--() { (*this).x-=1; return (*this); } constexpr ModInt operator++(int) { ModInt tmp(*this); ++(*this); return tmp; } constexpr ModInt operator--(int) { ModInt tmp(*this); --(*this); return tmp; } constexpr ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } constexpr ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } constexpr static int get_mod() { return mod; } }; template< int mod > constexpr ModInt operator+(const int64_t &p, const ModInt &m){ return ModInt(p) + m; }; template< int mod > constexpr ModInt operator-(const int64_t &p, const ModInt &m){ return ModInt(p) - m; }; template< int mod > constexpr ModInt operator*(const int64_t &p, const ModInt &m){ return ModInt(p) * m; }; template< int mod > constexpr ModInt operator/(const int64_t &p, const ModInt &m){ return ModInt(p) / m; }; constexpr int MOD = 1e9 + 7; using mint = ModInt< MOD >; namespace mintliteral{ constexpr mint operator""_m(unsigned long long x) { return mint(x); } } using namespace mintliteral; template struct ArithmeticImos{ int n, k; vector>> query; ArithmeticImos() = default; ArithmeticImos(int n, int k): n(n), k(k), query(n + 1) {} void add(int l, int r, const T &x){ query[l].emplace_back(0, x); query[r].emplace_back(r - l, -x); } vector build(vector a, vector c){ a.resize(n + k); for(int i = 0; i < n; ++i){ for(int j = 0; j < k; ++j){ a[i + k] += a[i + j] * c[j]; } } vector s(k), res(n); for(int i = 0; i < n; ++i){ T t = 0; for(int j = 0; j < k; ++j) t += s[j] * c[j]; s.erase(begin(s)); s.push_back(t); for(auto[l, x] : query[i]){ for(int j = 0; j < k; ++j) s[j] += a[l + j] * x; } res[i] = s[0]; } return res; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int k, n, m; cin >> k >> n >> m; ArithmeticImos imos(n, k); vector a(k), c(k); for(auto&&e : a) cin >> e; for(auto&&e : c) cin >> e; reverse(begin(c), end(c)); while(m--){ int l, r; cin >> l >> r; imos.add(l, r, 1); } for(auto&&e : imos.build(a, c)) cout << e << "\n" ; }