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()
    mans = 0
    ans = 0
    cr = 0
    j = -1
    ost = mg[-1][1]
    for i in rb:
        ans -= p * (i[0] - cr)
        cr = i[0]
        crr = i[1]
        while j >= len(mg) * (-1) and crr > 0:
            if crr >= ost:
                crr -= ost
                ans += ost * mg[j][0]
                ost = 0
            else:
                ans += mg[j][0] * crr
                ost -= crr
                crr = 0
            if ost == 0:
                j -= 1
                ost = mg[max(j, len(mg) * (-1))][1]
        mans = max(mans, ans)
    outf.write(str(mans))
    outf.close()