#include<iostream>
using namespace std;
#include <map>
typedef struct node
{
int index;
int value;
}node;
int main(void)
{
int n,a,b;
long long int sum=0;//大数用long long int ,要不然会溢出
cin>>n>>a>>b;
map<int,int>v1;
for(int i=0;i<a;i++)
{
node temp;
cin>>temp.index>>temp.value;
v1[temp.index]=temp.value;
}
for(int i=0;i<b;i++)
{
node temp;
cin>>temp.index>>temp.value;
if(v1[temp.index]!=0)
sum+=v1[temp.index]*temp.value;
}
cout<<sum;
return 0;
}
//必须用map动态创建键值对,要不然空间太大,内存不够
//也不能两个向量暴力匹配,时间复杂度太高,时间过不去