
h, w = map(int, input('h,w: ').split())
k = int(input('k: '))
ccs = []
for i in range(k):
    n, m = map(int, input('n,m: ').split())
    ccs.append((n, m))
ccs.sort(key = lambda x: -(x[0] * x[1]))
total = 0
for cc in ccs:
    if cc[0] <= h and cc[1] <= w:
        total += cc[0] * cc[1]
        w -= cc[1]
    cc = (cc[1], cc[0])
    if cc[0] <= h and cc[1] <= w:
        total += cc[0] *cc[1]
        w -= cc[1]
print(total)
