import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] nums1 = new int[2000];
int[] nums2 = new int[2000];
int m = sc.nextInt();
while (m-- > 0) {
int a = sc.nextInt();
int b = sc.nextInt();
nums1[b + 1000] = a;
}
int n = sc.nextInt();
while (n-- > 0) {
int a = sc.nextInt();
int b = sc.nextInt();
nums2[b + 1000] = a;
}
for (int i = 1999; i >= 0; i--) {
int num = nums1[i] + nums2[i];
if (num != 0) System.out.print(num + " " + (i - 1000) + " ");
}
}
}