if __name__ == "__main__": n = int(input()) member_list = [] for i in range(n): member_list.append(tuple(map(int, input().split(" ")))) m = int(input()) ans_list = [] for i in range(m): x, y = tuple(map(int, input().split(" "))) cnt = 0 for a, b in member_list: if x <= a and b <= y: cnt += 1 ans_list.append(cnt) if max(ans_list) == 0: print(0) else: ans_num = max(ans_list) for i in range(m): if ans_list[i] == ans_num: print(i + 1)