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

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

for i in range(n):
    n_i, m_i = map(int, input().split())
    carpets.append((n_i, m_i))

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

sum_area = 0

for carpet in carpets:
    n_i, m_i = carpet

    if (n_i <= h and m_i <= w) or (m_i <= h and n_i <= w):
        sum_area += n_i * m_i

        if n_i <= h:
            h -= n_i
        else:
            w -= n_i

print(sum_area)
