代码解答:
n, a, b = [int(x) for x in input().split()]
u = list()
for i in range(a):
u.append([int(x) for x in input().split()])
v = list()
for i in range(b):
v.append([int(x) for x in input().split()])
uindex = 0
vindex = 0
res = 0
while uindex < a and vindex < b:
if u[uindex][0] == v[vindex][0]:
res += u[uindex][1]*v[vindex][1]
uindex += 1
vindex += 1
elif u[uindex][0] > v[vindex][0]:
vindex += 1
else:
uindex += 1
print(res)