fin = open('fisher.in')
fout = open('fisher.out', 'w')
n, m, p = map(int, fin.readline().split())
x = [0] * n
a = [0] * n
for i in range(n):
    x[i], a[i] = map(int, fin.readline().split())
y = [0] * m
cb = [0] * m
B = 0
for i in range(m):
    y[i], b, c = map(int, fin.readline().split())
    cb[i] = (c, b)
    B += b
if p == 0:
    ans = 0
    if sum(a) >= B:
        for i in range(m):
            ans += cb[i][0] * cb[i][1]
    else:
        s = sum(a)
        cb.sort(reverse = True)
        i = 0
        while s > 0:
            ans += min(s, cb[i][1]) * cb[i][0]
            s -= min(s, cb[i][1])
            i += 1
    fout.write(str(ans))
fout.close()
fin.close()