Insects
시간 제한5초메모리 제한512 MB
흰 개미를 한 마리씩 추가할 때마다, x>=a이고 y>=b인 굶주린 흰 개미와 검은 개미 쌍이 생기지 않도록 먹여야 하는 최소 개미 수를 구한다.
문제
You have black ants in your terrarium, and the -th black ant lives at coordinate .
Each day for the next days, you will buy a new ant for your terrarium. You are only buying white ants, and the -th white ant that you are buying will live at coordinate .
Each day, you feed some of your insects. If you feed an insect, the insect will not be hungry in that day. If the -th white ant is hungry and the -th black ant is hungry, and and , they will fight. Find, for each day, the smallest number of ants to feed such that there are no fights.
입력
The first line contains one integer (): the number of black ants in your terrarium.
Each of the next lines contains the description of black ants. The -th of them contain two integers, ().
The next line contains one integer (): the number of days in which you are going to buy new white ants.
Each of the next lines contains the description of white ants in the order you buy them, such that the -th of them contains two integers, ().
Note that different ants can live at points with the same coordinates.
출력
Print integers, such that the -th of them equals the smallest number of ants that you should feed to avoid fights among the black ants and the white ants .