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()