#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main(){ int k,e; double c; double a[10010]; int ans = 0; // memset(v,0,sizeof(v)); memset(a,0,sizeof(a)); scanf("%d",&k); while(k--){ scanf("%d%lf",&e,&c); a[e]+=c; } scanf("%d",&k); while(k--){ scanf("%d%lf",&e,&c); a[e]+=c; } for(int i = 10009;i>=0;i--){ if(a[i])ans++; } printf("%d",ans); for(int i = 10009;i>=0;i--){ if(a[i]){ printf(" %d %.1f",i,a[i]); } } puts(""); return 0; }