#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
double con[2][1001] = {0.0};
double ans[2002] = {0.0};
vector<int> exist;
int main()
{
    int K, tmp1, mk;
    double tmp2;
    for (int i = 0; i < 2; i++)
    {
        scanf("%d", &K);
        if (i == 1)
            mk = exist.size() - 1;
        for (int j = 0; j < K; j++)
        {
            scanf("%d", &tmp1);
            scanf("%lf", &tmp2);
            con[i][tmp1] = tmp2;
            exist.push_back(tmp1);
        }
    }
    int cnt = 0;
    int sze = exist.size();
    for (int i = 0; i <= mk; i++)
    {
        for (int j = mk + 1; j < sze; j++)
            ans[exist[i] + exist[j]] += con[0][exist[i]] * con[1][exist[j]];
    }
    for (int k = 2000; k >= 0; k--)
    {
        if (ans[k] != 0)
            cnt++;
    }
    printf("%d", cnt);
    for (int k = 2000; k >= 0; k--)
    {
        if (ans[k] != 0)
            printf(" %d %.1f", k, ans[k]);
    }
    return 0;
}
