要关流
void solve()
{
int n,a,b;cin>>n>>a>>b;
map<int,int>tag;
rpp(i,a)
{
int id,x;cin>>id>>x;
tag[id] = x;
}
ll ans = 0;
rpp(i,b)
{
int id,x;cin>>id>>x;
if(tag[id])
ans+=tag[id]*x;
}
cout<<ans<<endl;
}
signed main()
{
fast;
int T = 1;
// cin >> T;
while (T--)
{
solve();
}
stop;
return 0;
}