import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
double x1[]=new double[1001];
double x2[]=new double[1001];
double x3[]=new double[2001];
int k1=scanner.nextInt();
for (int i=0;i<k1;i++){
int n1= scanner.nextInt();
double an1=scanner.nextDouble();
x1[n1]=an1;
}
int k2=scanner.nextInt();
for (int i=0;i<k2;i++){
int n2= scanner.nextInt();
double an2=scanner.nextDouble();
x2[n2]=an2;
}
for (int i=0;i<=1000;i++){
for (int j=0;j<=1000;j++){
x3[i+j]+=x1[i]*x2[j];
}
}
int count=0;
String str="";
for (int i=2000;i>=0;i--){
if (x3[i]!=0){
count++;
str = str + " " + i + " " + String.format("%.1f", x3[i]);
}
}
System.out.println(count+str);
}
}
之前没AC原来是因为x3的遍历要从2000开始