import java.io.*;
import java.util.*;

public class Pr3Fisher {
	public static void main(String[] args) throws IOException {
		new Pr3Fisher().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("fisher.in"));
		out = new PrintWriter("fisher.out");
		solve();
		out.flush();
	}

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		long p = nextInt();
		int[][] fish = new int[n][2];
		// long fish = 0;
		// long ans = 0;
		// long maxx = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 2; j++) {
				fish[i][j] = nextInt();
			}
		}
		// ans -= maxx * p;
		// System.err.println(ans);
		long[][] all = new long[m][3];
		for (int i = 0; i < m; i++) {
			all[i][0] = nextInt();
			all[i][1] = nextInt();
			all[i][2] = nextInt();
		}

		if (p == 0 || fish[0][0] > all[m - 1][0]) {
			Arrays.sort(all, new Comparator<long[]>() {

				@Override
				public int compare(long[] o1, long[] o2) {
					if (o1[2] != o2[2]) {
						return -Long.compare(o1[2], o2[2]);
					}
					return Long.compare(o1[1], o2[1]);
				}
			});
			long ans = 0;
			long curAns = 0;
			long curFish = 0;
			int curStall = 0;
			for (int i = 0; i < n; i++) {
				curAns -= fish[i][0] * p;
				if (i != 0) {
					curAns += fish[i - 1][0] * p;
				}
				curFish += fish[i][1];
				for (; curStall < m; curStall++) {
					if (curFish == 0) {
						break;
					}
					if (curFish >= all[curStall][1]) {
						curFish -= all[curStall][1];
						curAns += all[curStall][1] * all[curStall][2];
						continue;
					}
					curAns += curFish * all[curStall][2];
					all[curStall][1] -= curFish;
					curFish = 0;
					break;
				}
				ans = Math.max(ans, curAns);
			}
			out.println(ans);
			return;
		}
		long[] allx = new long[n + m];
		for (int i = 0; i < n; i++) {
			allx[i] = fish[i][0];
		}
		for (int i = 0; i < m; i++) {
			allx[i + n] = all[i][0];
		}
		Arrays.sort(allx);
		Arrays.sort(all, new Comparator<long[]>() {

			@Override
			public int compare(long[] o1, long[] o2) {
				if (o1[2] != o2[2]) {
					return -Long.compare(o1[2], o2[2]);
				}
				return Long.compare(o1[1], o2[1]);
			}
		});
		long ans = 0;
		long lfish = 0;
		int li = 0;
		for (int i = 0; i < n + m; i++) {
			if (i > 0 && allx[i] == allx[i - 1]) {
				continue;
			}
			long fishNum = lfish;
			for (; li < n; li++) {
				if (fish[li][0] > allx[i])
					break;
				fishNum += fish[li][1];
			}
			lfish = fishNum;
			long curAns = 0;
			for (int j = 0; j < m; j++) {
				if (fishNum == 0) {
					break;
				}
				if (all[j][0] > allx[i])
					continue;

				if (fishNum >= all[j][1]) {
					fishNum -= all[j][1];
					curAns += all[j][1] * all[j][2];
					continue;
				}
				curAns += fishNum * all[j][2];
				fishNum = 0;
			}
			ans = Math.max(ans, curAns - allx[i] * p);
		}
		out.println(ans);
	}
}
