#include<stdio.h> #include<vector> #include<string.h> using namespace std; struct element{ int n; float an; }; float result[2000]; int main(){ int k1, k2,num=0; memset(result, 0, sizeof result); scanf("%d", &k1); vector<element>v1(k1); for (int i = 0; i < k1; i++){ scanf("%d %f", &v1[i].n, &v1[i].an); } scanf("%d", &k2); vector<element>v2(k2); for (int i = 0; i < k2; i++){ scanf("%d %f", &v2[i].n, &v2[i].an); for (int j = 0; j < k1; j++){ int a=v2[i].n + v1[j].n; result[a] += v2[i].an*v1[j].an; } } for (int i = v1[0].n + v2[0].n; i >= 0; i--){ if (result[i] != 0)num++; } printf("%d", num); for (int i = v1[0].n + v2[0].n; i >= 0; i--){ if (result[i] != 0){ printf(" %d %.1f",i, result[i]); } } printf("\n"); return 0; }