inf = open("fisher.in", "r")
outf = open("fisher.out", "w")
n, m, p = map(int, inf.readline().split())
rb = []
vrb = 0
for i in range(n):
    rb.append(tuple(map(int, inf.readline().split())))
    vrb += rb[-1][1]
mg = []
for i in range(m):
    a, b, c = map(int, inf.readline().split())
    mg.append([c, b, a])
if p == 0:
    mg.sort()
    ans = 0
    i = -1
    while i >= len(mg) * (-1) and vrb > 0:
        ans += min(mg[i][0] * vrb, mg[i][0] * mg[i][1])
        vrb -= mg[i][1]
        i -= 1
    outf.write(str(ans))
    outf.close()
else:
    mg.sort()
    j = -1
    ost = mg[-1][1]
    mans = 0
    ans = 0
    crx = 0
    for i in rb:
        print(i)
        ans -= (i[0] - crx) * p
        crx = i[0]
        crr = i[1]
        while ost <= crr:
            ans += mg[j][0] * mg[j][1]
            crr -= mg[j][1]
            ost = mg[j - 1][1]
            j -= 1
        ans += mg[j][0] * crr
        ost -= crr
        mans = max(mans, ans)
    outf.write(str(mans))
    outf.close()