h, w = map(int, input().split())

n = int(input())
carpets = []

for _ in range(n):
    n, m = map(int, input().split())
    carpets.append((n, m))

# Сортируем ковры по убыванию площади
carpets.sort(key=lambda x: -(x[0] * x[1]))

max_total_area = 0

for carpet in carpets:
    n, m = carpet
    if (n <= h and m <= w) or (n <= w and m <= h):
        max_total_area += n * m
        if n <= h:
            h -= n
        else:
            w -= n

print(max_total_area)
