Vasyl has integers: x_1, x_2,..., x_N. You must help him to answer the queries of two types:
AND L R - in this case find the minimum value x_{i_1} AND x_{i_2} AND ... AND x_{i_k}, where \{x_{i_k}\} is some nonempty subset, L \le i_1 < i_2 < ... < i_k \le R, 1 \le L \le R \le N.
OR L R - in this case find the minimum value x_{i_1} OR x_{i_2} OR ... OR x_{i_k}, where \{x_{i_k}\} is some nonempty subset, L \le i_1 < i_2 < ... < i_k \le R, 1 \le L \le R \le N.
The first line contains number , 1 \le N \le 100000. Next line contains numbers x_i, 0 \le x_i \le 10^9. Then the number of queries , 1 \le M \le 100000, is given. Each of the next lines contains one query.
For each query print the answer in separate line.
Example 1