#include<iostream>
#define maxn 1002
using namespace std;

double a[maxn];
double b[maxn];
double c[maxn];
int main(){
   
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
   
		int t1;double t2;
		cin>>t1>>t2;
		a[t1]=t2;
	}
	cin>>n;
	for(int i=0;i<n;i++){
   
		int t1; double t2;
		cin>>t1>>t2;
		b[t1]=t2;
	}
	int sum=0;
	for(int i=1001;i>=0;i--)
	{
   
		c[i]=a[i]+b[i];
		if(c[i])
		sum++;
	}
	cout<<sum;
	for(int i=1001;i>=0;i--){
   
		if(c[i]){
   
		printf(" %d %.1f",i,c[i]);
		}
	}
}