#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#include<iomanip>
using namespace std;
const int N = 1000+5;
map<int, double>a, b, ans;
int main() {
int n, e;
double c;
cin >> n;
for(int i=0; i<n; i++) {
cin >> e >> c;
a[e] += c;
}
cin >> n;
for(int i=0; i<n; i++) {
cin >> e >> c;
b[e] += c;
}
int e1, e2;
double c1, c2;
for(map<int, double>::iterator it1=a.begin(); it1!=a.end(); it1++) {
e1 = it1->first;
c1 = it1->second;
if(c1 == 0) continue;
for(map<int, double>::iterator it2=b.begin(); it2!=b.end(); it2++) {
e2 = it2->first;
c2 = it2->second;
if(c2 == 0) continue;
ans[e1+e2] += c1*c2;
// cout<< e1 << ":" << c1 << " " << e2 << c2 << " "<< e1+e2 << " " << ans[e1+e2] << endl;
}
}
int cnt=0;
for(int i=0; i<=2000; ++i) {
if(ans[i])
cnt++;
}
cout<<cnt;
for(int i=2000; i>=0; --i)
if(ans[i])
cout<<" "<<i<<" "<<setiosflags(ios::fixed)<<setprecision(1)<<ans[i];
return 0;
}
//20分
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
const int N = 1000+5;
map<int, double>a, b, ans;
int main() {
int n, e;
double c;
cin >> n;
for(int i=0; i<n; i++) {
cin >> e >> c;
a[e] += c;
}
cin >> n;
for(int i=0; i<n; i++) {
cin >> e >> c;
b[e] += c;
}
int e1, e2;
double c1, c2;
for(map<int, double>::iterator it1=a.begin(); it1!=a.end(); it1++) {
e1 = it1->first;
c1 = it1->second;
if(c1 == 0) continue;
for(map<int, double>::iterator it2=b.begin(); it2!=b.end(); it2++) {
e2 = it2->first;
c2 = it2->second;
if(c2 == 0) continue;
ans[e1+e2] += c1*c2;
// cout<< e1 << ":" << c1 << " " << e2 << c2 << " "<< e1+e2 << " " << ans[e1+e2] << endl;
}
}
if(ans.size() == 0) {
cout << 0;
} else {
map<int, double>::iterator it=ans.end();
it--;
cout << ans.size();
for( ; it!= ans.begin(); it--) {
e2 = it->first;
c2 = it->second;
printf(" %d %.1f", e2, c2);
}
e2 = it->first;
c2 = it->second;
printf(" %d %.1f", e2, c2);
}
return 0;
}