h, w = map(int, input().split())
dp = [[0] * (w+1) for _ in range(h+1)]

for _ in range(int(input())):
    n, m = map(int, input().split())
    for i in range(h-n+1):
        for j in range(w-m+1):
            dp[i+n][j+m] = max(dp[i+n][j+m], dp[i][j] + n*m)

print(dp[h][w])

