a1 = int(input()) a2 = int(input()) N = int(input()) list = [] for i in range(N): n = input() m = n.split() p = [int(i) for i in m] list.append(p) a3 = 0 while list != []: c = list[0] list[0] = [] newlist = [i1 for i1 in list if i1 != c] d = len(list) - len(newlist) a3 = a3 + d else: a = (a1 + a2) * a3 print(a)