Joining Flows
문제
Having recently taken over the Wonka Factory, Charlie is now in charge of the day-to-day production of the various chocolate products made there. While this may seem like a cushy job with an all-you-can-eat-chocolate perk, it also comes with the difficult responsibility of keeping the (somewhat convoluted and complicated) production lines working.
The heart of the factory is the Chocolate River, where raw molten chocolate flows from chocolate-producing faucets, to outlets where different types of pralines and choclate bars are made. The 'th of the chocolate faucets produces chocolate at some fixed temperature , and the amount of chocolate flowing from the faucet can be adjusted to any value between and millilitres per second. Suppose the taps are adjusted to produce millilitres of chocolates per second respectively (where ). Then the total flow in the Chocolate river is , and its temperature is the weighted average \[ \frac{x_1 t_1 + x_2t_2 + \ldots + x_kt_k}{x_1 + x_2 + \ldots + x_k} \] (each faucet produces grade A quality chocolate which instantly mixes with the chocolate from the other faucets).
Each type of praline and chocolate bar produced at the factory requires the Chocolate River to be adjusted to have a specific temperature and flow level. Charlie recently came across a long list of new praline recipes, and would now like to figure out which of these are even possible to make at the factory. Write a program to determine, for each of the new recipes, if its required temperature and flow level is possible to achieve with some setting of the faucets.
입력
The first line of input contains an integer (), the number of taps. Then follow lines, describing the taps. The 'th of these lines contains the three integers , , and (, ) describing the 'th faucet.
Next follows a line containing an integer (), the number of new recipes to check. Then follows lines, each describing a recipe. A recipe is described by two integers and ( and ), where is the chocolate temperature and the chocolate flow needed for this recipe.
출력
For each of the recipes, print one line with the string "yes" if it is possible to achieve the desired combination of chocolate temperature and flow, and "no" otherwise.
예제
예제 1
2 50 0 100 100 50 100 3 20 75 75 150 75 90
no yes no