#include using namespace std; #define rep2(i, m, n) for(int i=int(m); i= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) { if ((x -= a.x) < 0) x += MOD; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;} mint operator+(const mint a) const { return mint(*this) += a;} mint operator-(const mint a) const { return mint(*this) -= a;} mint operator*(const mint a) const { return mint(*this) *= a;} }; istream& operator>>(istream& is, mint& a) { return is >> a.x;} ostream& operator<<(ostream& os, const mint& a) { return os << a.x;} using Vm = vector; using VVm = vector; int main() { int k, n, m; cin >> k >> n >> m; // assert // assert(1 <= k && k <= 200); assert(1 <= n && n <= int(1e5)); assert(1 <= m && m <= int(1e5)); //////////// Vm a(k+n), c(k+1); c[0] = -1; rep(i, k) { int x; cin >> x; // assert // assert(0 <= x && x <= int(1e9)); //////////// a[i] = x; } rep(i, k) { int x; cin >> x; // assert // assert(0 <= x && x <= int(1e9)); //////////// c[i+1] = x; } rep2(i, k, n) rep2(j, 1, k+1) a[i] += c[j]*a[i-j]; VVm d(n, Vm(k)); rep(i, n) { d[i][0] = c[0]*a[i]; rep2(j, 1, k) d[i][j] += d[i][j-1] + c[j]*a[i-j]; } Vm y(n); rep(_, m) { int l, r; cin >> l >> r; // assert // assert(0 <= l && l < r && r <= n); //////////// rep2(i, l, min(l+k, n)) y[i] += d[i-l][i-l]; rep2(i, r, min(r+k, n)) y[i] -= d[i-l][i-r]; } Vm x(n); rep(i, n) { x[i] = - y[i]; rep2(j, 1, min(i, k)+1) x[i] += c[j]*x[i-j]; cout << x[i] << "\n"; } return 0; }