import sys sys.setrecursionlimit(100000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 def main(): N = int(input()) want = [tuple(map(int,input().split())) for _ in range(N)] M = int(input()) mentaiko = [tuple(map(int,input().split())) for _ in range(M)] bought = [0] * M max_bought = 0 for a,b in want: for i,(x,y) in enumerate(mentaiko): if x <= a and b <= y: bought[i] += 1 max_bought = max(max_bought,bought[i]) if max_bought == 0: print(0) else: ans = [i + 1 for i in range(M) if bought[i] == max_bought] print('\n'.join(map(str,ans))) if __name__ == '__main__': main()