#include <iostream> #include <algorithm> #include <cmath> #include <cstring> #define maxn 2010 using namespace std; int a[maxn] = {0}; int b[maxn] = {0}; bool flag[maxn]={0}; int main() { int n, m; cin >> n; for (int i = 0; i < n; i++) { int x, c; cin >> x >> c; flag[c + 1000]=1; a[c + 1000] = x; } cin>>m; for (int i = 0; i < m; i++) { int x, c; cin >> x >> c; flag[c + 1000]=1; b[c + 1000] = x; } for(int i=2005;i>=0;i--) { if(flag[i] && a[i]+b[i] )cout<<a[i]+b[i]<<" "<<i - 1000<<" "; } } // 64 位输出请用 printf("%lld")