Have you ever thought about how many people are transported by trams every year in a city with a ten-million population where one in three citizens uses tram twice a day?
Assume that there arencities with trams on the planet Earth. Statisticians counted for each of them the number of people transported by trams during last year. They compiled a table, in which cities were sorted alphabetically. Since city names were inessential for statistics, they were later replaced by numbers from 1 ton. A search engine that works with these data must be able to answer quickly a query of the following type: is there among the cities with numbers fromltorsuch that the trams of this city transported exactlyxpeople during last year. You must implement this module of the system.
Input
The first line contains the integern, 0 <n< 70000. The second line contains statistic data in the form of a list of integers separated with a space. In this list, theith number is the number of people transported by trams of theith city during last year. All numbers in the list are positive and do not exceed 1091. In the third line, the number of queriesqis given,0 <q< 70000.The nextqlines contain the queries. Each of them is a triple of integersl,r, andxseparated with a space;1 ≤l≤r≤n; 0 <x< 109.
Output
Output a string of lengthqin which theith symbol is “1” if the answer to theith query is affirmative, and “0” otherwise.
Sample
inputoutput
51234567 666666 3141593 666666 434343451 5 31415931 5 5782022 4 6666664 4 71356101 1 123456710101
Problem Author:Alexander IpatovProblem Source:The 12th Urals Collegiate Programing Championship, March 29, 2008
,往往为了自己的不能失败,而处心积虑前怕狼后怕虎,