#include<iostream> using namespace std; #include<stdio.h> #include<memory.h> double exp[1001]; int main() { int e; double c; int N; int count=0; memset(exp,0,sizeof(exp)); for(int i=0;i<2;i++) { cin>>N; while(N--) { cin>>e; cin>>c; if(exp[e]==0) count++; exp[e]+=c; if(exp[e]==0) count--; } } cout<<count; for(int i=1000;i>=0;i--) { if(exp[i]!=0) printf(" %d %.1f",i,exp[i]); } }