#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 = 200005;
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];
set<int> pos;

long long all_fish = 0, all_city = 0;
unordered_map<int, int> fish_id, city_id;
long long best = 0;

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

inline int getFishPos(int x) {
    return fish_id.find(x) == fish_id.end() ? -1 : fish_id[x];
}

inline int getCityPos(int x) {
    return city_id.find(x) == city_id.end() ? -1 : city_id[x];
}

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

    cin >> n >> m >> p;
    for (int i = 0; i < n; i++) {
        cin >> fish[i].x >> fish[i].a;
        pos.insert(fish[i].x);
    }
    for (int i = 0; i < m; i++) {
        cin >> city[i].y >> city[i].b >> city[i].c;
        pos.insert(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;
    });

    for (int i = 0; i < n; i++)
        fish_id[fish[i].x] = i;
    for (int i = 0; i < m; i++)
        city_id[city[i].y] = i;

    for (int x : pos) {
        int i = getFishPos(x);
        int j = getCityPos(x);
        if (i != -1) {
            all_fish += fish[i].a;
        }
        if (j != -1) {
            all_city += city[j].b;
            insert(city[j].b, city[j].c);
        }
        best = max(best, getResult() - p * 1ll * x);
    }

    cout << best;

	return 0;
}


