{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThere are \u003ci\u003en\u003c/i\u003e planets in Betelgeuse star system. Each planet is inhabited \r\nby a single race, different planets can be inhabited by the same race. All planets move in circular orbits,\r\nlie on a single ray starting at the star and have same constant angular velocity. Tourists\r\nfrom other galaxies often ask the Ministry of Space Tourism to help them plan their journey.\r\nThey would like to be escorted to a planet, from which they can start their individual journey\r\non their own small spaceship.\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eSpaceships of all the tourists are equipped with a small fuel tank, which allows to\r\ncover at most \u003ci\u003ed\u003c/i\u003e astronomical units without reloading. Such a reloading can be made on any\r\nplanet of the system. Moreover, each ship can operate only in a fixed range of distances to the\r\nstar, where he can use the radiation energy. A tourist can be escorted to a planet only if\r\nthe distance from this planet to the star fall into this range.\u003c/div\u003e\u003c/div\u003e\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe Ministry ordered you to calculate the maximal number of races each tourist can come in contact with.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eThe first line contains space-separated integers \u003ci\u003en\u003c/i\u003e, \u003ci\u003es\u003c/i\u003e and \u003ci\u003ed\u003c/i\u003e (1 ≤ \u003ci\u003en\u003c/i\u003e, \u003ci\u003es\u003c/i\u003e, \u003ci\u003ed\u003c/i\u003e ≤ 10\u003csup\u003e5\u003c/sup\u003e),\r\nwhich are the number of planets in Betelgeuse star system, the number of known races and the maximal\r\ndistance each ship can fly without reloading, respectively. Each of the next \u003ci\u003en\u003c/i\u003e lines describes a planet and contains two space-separated\r\npositive integers which are a distance from this planet to the star and a number of race which lives on this planet, respectively.\r\nRaces are numbered with integers from 1 to \u003ci\u003es\u003c/i\u003e. The distances from planets to Betelgeuse are all different and don\u0027t\r\nexceed 10\u003csup\u003e6\u003c/sup\u003e astronomical units.\r\nThe next line contains a number of tourists \u003ci\u003em\u003c/i\u003e (1 ≤ \u003ci\u003em\u003c/i\u003e ≤ 10\u003csup\u003e5\u003c/sup\u003e). Each of the next \u003ci\u003em\u003c/i\u003e lines contains\r\ntwo space-separated positive integers, which are the minimal and the maximal possible distance to the star at which the ship of the tourist\r\ncan operate in. These distances doesn\u0027t exceed 10\u003csup\u003e6\u003c/sup\u003e.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"problem_par\"\u003e\u003cdiv class\u003d\"problem_par_normal\"\u003eFor each tourist, you should output the maximal number of races he can come in contact with.\u003c/div\u003e\u003c/div\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 5 11\r\n10 1\r\n50 2\r\n30 1\r\n20 1\r\n60 3\r\n2\r\n5 65\r\n15 45\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}