#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define size(x) (int) x.size()
#define all(x) x.begin(), x.end()

const int maxn = 500005;
const int inf = (int) 1e9;
const long long mod = (long long) 1e9 + 7;
const long long l_inf = (long long) 4e18;

struct Fish {
    int x, a;
};

struct City {
    int y, b, c;
};

struct TNode {
    int x;
    long long y;
    int l, r;
    int w;
    long long sum, all;
    TNode(int x = -1, int w = -1) :
            x(x), w(w) {
        y = ((1ll * rand()) << 32ll) ^ (1ll * rand());
        l = r = -1;
        sum = w;
        all = 1ll * w * x;
    }
};

int n, m, p;
Fish fish[maxn];
City city[maxn];
int pos[2 * maxn];

long long all_fish = 0;
long long best = 0;

int sz = 0, root = -1;
TNode tree[maxn];

inline int createNode(int b, int c) {
    tree[sz] = TNode(c, b);
    return sz++;
}

inline long long getSum(int node) {
    if (node == -1)
        return 0;
    return tree[node].sum;
}

inline long long getAll(int node) {
    if (node == -1)
        return 0;
    return tree[node].all;
}

inline void updateNode(int node) {
    tree[node].sum = getSum(tree[node].l) + getSum(tree[node].r) + tree[node].w;
    tree[node].all = getAll(tree[node].l) + getAll(tree[node].r) + 1ll * tree[node].w * tree[node].x;
}

int merge(int l, int r) {
    if (l == -1)
        return r;
    if (r == -1)
        return l;
    if (tree[l].y < tree[r].y) {
        tree[l].r = merge(tree[l].r, r);
        updateNode(l);
        return l;
    } else {
        tree[r].l = merge(l, tree[r].l);
        updateNode(r);
        return r;
    }
}

void splitX(int v, int cp, int &l, int &r) {
    if (v == -1) {
        l = r = -1;
        return;
    }
    if (tree[v].x >= cp) {
        splitX(tree[v].r, cp, l, r);
        tree[v].r = l;
        l = v;
    } else {
        splitX(tree[v].l, cp, l, r);
        tree[v].l = r;
        r = v;
    }
    updateNode(v);
}

void splitW(int v, long long cp, int &l, int &r) {
    if (v == -1) {
        l = r = -1;
        return;
    }
    if (getSum(tree[v].l) + tree[v].w <= cp) {
        splitW(tree[v].r, cp - getSum(tree[v].l) - tree[v].w, l, r);
        tree[v].r = l;
        l = v;
    } else {
        splitW(tree[v].l, cp, l, r);
        tree[v].l = r;
        r = v;
    }
    updateNode(v);
}

int getLeftNode(int v) {
    if (v == -1)
        return 0;
    if (tree[v].l == -1)
        return tree[v].x;
    return getLeftNode(tree[v].l);
}

inline void insert(int b, int c) {
    int node = createNode(b, c);
    int l, r;
    splitX(root, c, l, r);
    root = merge(l, merge(node, r));
}

inline long long getResult() {
    int l, r;
    splitW(root, all_fish, l, r);
    long long result = getAll(l) + getLeftNode(r) * (all_fish - getSum(l));
    root = merge(l, r);
    return result;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    srand(566);

//#ifndef LOCAL
#define FILE "fisher"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
//#endif

    scanf("%d%d%d", &n, &m, &p);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &fish[i].x, &fish[i].a);
        pos[i] = fish[i].x;
    }
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &city[i].y, &city[i].b, &city[i].c);
        pos[n + i] = city[i].y;
    }

    sort(fish, fish + n, [](Fish &a, Fish &b) {
         return a.x < b.x;
    });
    sort(city, city + m, [](City &a, City &b) {
         return a.y < b.y;
    });
    sort(pos, pos + n + m);

    int i = 0, j = 0;
    for (int it = 0; it < n + m; it++) {
        if (it > 0 && pos[it] == pos[it - 1])
            continue;
        int x = pos[it];
        while (i < n && fish[i].x <= x) {
            all_fish += fish[i].a;
            i++;
        }
        while (j < m && city[j].y <= x) {
            insert(city[j].b, city[j].c);
            j++;
        }
        best = max(best, getResult() - p * 1ll * x);
    }

    printf("%lld", best);

    return 0;
}
