#include <bits/stdc++.h>

#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using sll = __int128;

const int maxn = 1e6 + 10;

int a[maxn], b[maxn], p[maxn];

void solve() {
    int n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for (int i = 1; i <= n; i++) cin >> p[i];
    int cur = 0;
    int mx = 0;
    for (int i = 1; i <= n; i++) {
        cur += a[i] + b[i] * (i - 1);
        mx = max(mx, cur);
    }
    cout << mx;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
    }
}