#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1020050909;
const ll INF = 5e18;
const int SIZE = 1e6 + 5;
const int MAX = 1e6;
struct Line {
int m = 0;
ll k = -INF;
Line() {}
Line (int m, ll k) : m (m), k (k) {}
ll operator () (int x) {
return 1ll * m * x + k;
}
};
struct Node {
Line line;
int ls, rs;
Node() {}
Node (Line line) : ls (0), rs (0), line (line) {}
} node[SIZE];
int root, cnt;
int newnode (Line line) {
node[++cnt] = Node (line);
return cnt;
}
void Ins (int &pos, int l, int r, Line line) {
if (pos == 0) {
pos = newnode (line);
return;
}
Node &nd = node[pos];
if (l == r) {
if (line (l) > nd.line (l)) swap (line, nd.line);
return;
}
int mid = (l + r) / 2;
if (line (mid) > nd.line (mid)) swap (line, nd.line);
if (line.m <= nd.line.m) Ins (nd.ls, l, mid, line);
else Ins (nd.rs, mid + 1, r, line);
}
ll Que (int pos, int l, int r, int x) {
if (pos == 0) return -INF;
Node nd = node[pos];
if (l == r) return nd.line (x);
int mid = (l + r) / 2;
return max (nd.line (x), x <= mid ? Que (nd.ls, l, mid, x) : Que (nd.rs, mid + 1, r, x));
}
int n, k;
ll ans, dp[SIZE];
vector<int> L[SIZE], R[SIZE];
int a[SIZE], b[SIZE], m[SIZE];
int main() {
ios::sync_with_stdio (false), cin.tie (0);
cin >> n >> k;
for (int i = 0; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
for (int i = 1; i <= n; i++) cin >> m[i];
for (int i = 1; i <= n; i++) {
int l = max (0, b[i] - k + 1), r = b[i];
L[l].emplace_back (i);
R[r].emplace_back (i);
dp[i] = -INF;
}
for (int i = 0; i <= n; i++) {
if (i % k == 0) {
int l = max (0, i - k + 1), r = i;
root = cnt = 0;
while (r >= l) {
Ins (root, 0, MAX, Line (-a[r], dp[r]));
for (int pos : L[r]) {
dp[pos] = max (dp[pos], Que (root, 0, MAX, m[pos]) + 1ll * m[pos] * (a[pos] + 1));
}
r--;
}
root = cnt = 0;
}
Ins (root, 0, MAX, Line (-a[i], dp[i]));
for (int pos : R[i]) {
dp[pos] = max (dp[pos], Que (root, 0, MAX, m[pos]) + 1ll * m[pos] * (a[pos] + 1));
}
ans += dp[i] % MOD;
}
cout << ans % MOD << '\n';
}
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk8zIikKI3ByYWdtYSBHQ0MgdGFyZ2V0KCJwb3BjbnQiKQojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnVzaW5nIGxsID0gbG9uZyBsb25nOwoKY29uc3QgaW50IE1PRCA9IDEwMjAwNTA5MDk7CmNvbnN0IGxsIElORiA9IDVlMTg7CmNvbnN0IGludCBTSVpFID0gMWU2ICsgNTsKY29uc3QgaW50IE1BWCA9IDFlNjsKCnN0cnVjdCBMaW5lIHsKICAgIGludCBtID0gMDsKICAgIGxsIGsgPSAtSU5GOwogICAgTGluZSgpIHt9CiAgICBMaW5lIChpbnQgbSwgbGwgaykgOiBtIChtKSwgayAoaykge30KICAgIGxsIG9wZXJhdG9yICgpIChpbnQgeCkgewogICAgICAgIHJldHVybiAxbGwgKiBtICogeCArIGs7CiAgICB9Cn07CgpzdHJ1Y3QgTm9kZSB7CiAgICBMaW5lIGxpbmU7CiAgICBpbnQgbHMsIHJzOwogICAgTm9kZSgpIHt9CiAgICBOb2RlIChMaW5lIGxpbmUpIDogbHMgKDApLCBycyAoMCksIGxpbmUgKGxpbmUpIHt9Cn0gbm9kZVtTSVpFXTsKCmludCByb290LCBjbnQ7CgppbnQgbmV3bm9kZSAoTGluZSBsaW5lKSB7CiAgICBub2RlWysrY250XSA9IE5vZGUgKGxpbmUpOwogICAgcmV0dXJuIGNudDsKfQoKdm9pZCBJbnMgKGludCAmcG9zLCBpbnQgbCwgaW50IHIsIExpbmUgbGluZSkgewogICAgaWYgKHBvcyA9PSAwKSB7CiAgICAgICAgcG9zID0gbmV3bm9kZSAobGluZSk7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgTm9kZSAmbmQgPSBub2RlW3Bvc107CiAgICBpZiAobCA9PSByKSB7CiAgICAgICAgaWYgKGxpbmUgKGwpID4gbmQubGluZSAobCkpIHN3YXAgKGxpbmUsIG5kLmxpbmUpOwogICAgICAgIHJldHVybjsKICAgIH0KICAgIGludCBtaWQgPSAobCArIHIpIC8gMjsKICAgIGlmIChsaW5lIChtaWQpID4gbmQubGluZSAobWlkKSkgc3dhcCAobGluZSwgbmQubGluZSk7CiAgICBpZiAobGluZS5tIDw9IG5kLmxpbmUubSkgSW5zIChuZC5scywgbCwgbWlkLCBsaW5lKTsKICAgIGVsc2UgSW5zIChuZC5ycywgbWlkICsgMSwgciwgbGluZSk7Cn0KCmxsIFF1ZSAoaW50IHBvcywgaW50IGwsIGludCByLCBpbnQgeCkgewogICAgaWYgKHBvcyA9PSAwKSByZXR1cm4gLUlORjsKICAgIE5vZGUgbmQgPSBub2RlW3Bvc107CiAgICBpZiAobCA9PSByKSByZXR1cm4gbmQubGluZSAoeCk7CiAgICBpbnQgbWlkID0gKGwgKyByKSAvIDI7CiAgICByZXR1cm4gbWF4IChuZC5saW5lICh4KSwgeCA8PSBtaWQgPyBRdWUgKG5kLmxzLCBsLCBtaWQsIHgpIDogUXVlIChuZC5ycywgbWlkICsgMSwgciwgeCkpOwp9CgppbnQgbiwgazsKbGwgYW5zLCBkcFtTSVpFXTsKdmVjdG9yPGludD4gTFtTSVpFXSwgUltTSVpFXTsKaW50IGFbU0laRV0sIGJbU0laRV0sIG1bU0laRV07CgppbnQgbWFpbigpIHsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvIChmYWxzZSksIGNpbi50aWUgKDApOwogICAgY2luID4+IG4gPj4gazsKICAgIGZvciAoaW50IGkgPSAwOyBpIDw9IG47IGkrKykgY2luID4+IGFbaV07CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIGNpbiA+PiBiW2ldOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSBjaW4gPj4gbVtpXTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgewogICAgICAgIGludCBsID0gbWF4ICgwLCBiW2ldIC0gayArIDEpLCByID0gYltpXTsKICAgICAgICBMW2xdLmVtcGxhY2VfYmFjayAoaSk7CiAgICAgICAgUltyXS5lbXBsYWNlX2JhY2sgKGkpOwogICAgICAgIGRwW2ldID0gLUlORjsKICAgIH0KICAgIGZvciAoaW50IGkgPSAwOyBpIDw9IG47IGkrKykgewogICAgICAgIGlmIChpICUgayA9PSAwKSB7CiAgICAgICAgICAgIGludCBsID0gbWF4ICgwLCBpIC0gayArIDEpLCByID0gaTsKICAgICAgICAgICAgcm9vdCA9IGNudCA9IDA7CiAgICAgICAgICAgIHdoaWxlIChyID49IGwpIHsKICAgICAgICAgICAgICAgIElucyAocm9vdCwgMCwgTUFYLCBMaW5lICgtYVtyXSwgZHBbcl0pKTsKICAgICAgICAgICAgICAgIGZvciAoaW50IHBvcyA6IExbcl0pIHsKICAgICAgICAgICAgICAgICAgICBkcFtwb3NdID0gbWF4IChkcFtwb3NdLCBRdWUgKHJvb3QsIDAsIE1BWCwgbVtwb3NdKSArIDFsbCAqIG1bcG9zXSAqIChhW3Bvc10gKyAxKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByLS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcm9vdCA9IGNudCA9IDA7CiAgICAgICAgfQogICAgICAgIElucyAocm9vdCwgMCwgTUFYLCBMaW5lICgtYVtpXSwgZHBbaV0pKTsKICAgICAgICBmb3IgKGludCBwb3MgOiBSW2ldKSB7CiAgICAgICAgICAgIGRwW3Bvc10gPSBtYXggKGRwW3Bvc10sIFF1ZSAocm9vdCwgMCwgTUFYLCBtW3Bvc10pICsgMWxsICogbVtwb3NdICogKGFbcG9zXSArIDEpKTsKICAgICAgICB9CiAgICAgICAgYW5zICs9IGRwW2ldICUgTU9EOwogICAgfQogICAgY291dCA8PCBhbnMgJSBNT0QgPDwgJ1xuJzsKfQ==