#include<stdio.h> #include<string.h> #define N 2 #define M 1001 int main(){ int i,j,k,n,t=0,temp=0; float value; float a[M]={0}; for(i=0;i<M;i++){ a[i] = 0; } for(i=0;i<N;i++){ while(scanf("%d", &k) && (k>=1 && k<=10)){ for(j=0;j<k;j++){ scanf("%d %f", &n, &value); if(a[n] == 0 && value != 0) { t++; temp = 1; } a[n] += value; if(a[n] == 0 && temp) t--; } break; } } printf("%d", t); for(i=M-1;i>=0;i--){ if(a[i]!=0){ printf(" %d", i); printf(" %.1f", a[i]); } } return 0; }