#include <bits/stdc++.h>

#define int ll
#define ll unsigned long long

using namespace std;

int n, m, p;
vector<int> x, a, y, b, c;

int Sol1() {
    int sum = 0;
    for (int i = 0; i < n; ++i)
        sum += a[i];
    vector<pair<int, int> > C(m);
    for (int i = 0; i < m; ++i)
        C[i] = {c[i], b[i]};
    sort(C.begin(), C.end());
    int res = 0;
    for (int i = m - 1; i >= 0 && sum > 0; --i) {
        res += min(sum, C[i].second) * C[i].first;
        sum -= C[i].second;
    }
    return res;
}

int Sol2() {
    vector<pair<int, int> > X(n);
    vector<pair<int, int> > C(m);
    for (int i = 0; i < n; ++i)
        X[i] = {x[i], a[i]};
    for (int i = 0; i < m; ++i)
        C[i] = {c[i], b[i]};
    sort(C.begin(), C.end());
    int res = 0, last_x = 0, ans = 0, cur_pos = m - 1;
    for (int i = 0; i < m; ++i) {
        int want = X[i].second;
        while (want > 0 && cur_pos >= 0) {
            if (want >= C[cur_pos].second) {
                res += C[cur_pos].second * C[cur_pos].first;
                want -= C[cur_pos].second;
                C[cur_pos].second = 0;
                --cur_pos;
            }
            else {
                res += want * C[cur_pos].first;
                C[cur_pos].second -= want;
                want = 0;
            }
        }
        if (res < X[i].first - last_x * p)
            break;
        res -= (X[i].first - last_x) * p;
        last_x = X[i].first;
        ans = max(ans, res);
    }
    return ans;
}

#undef int
int main() {
    #define int ll
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin >> n >> m >> p;
    x.resize(n);
    a.resize(n);
    y.resize(m);
    b.resize(m);
    c.resize(m);
    for (int i = 0; i < n; ++i)
        cin >> x[i] >> a[i];
    for (int i = 0; i < m; ++i)
        cin >> y[i] >> b[i] >> c[i];
    if (p == 0)
        cout << Sol1() << endl;
    else if (y[m - 1] < x[0])
        cout << Sol2() << endl;
    else
        cout << "Ochen' zhal'\n";
    return 0;
}
