Bitwise Queries

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

You are given an array aa of size nn and you need to perform mm queries on it. There are three types of queries:

  1. "& ll rr xx": change a_ia\_i to (a_ia\_i AND xx) for all ii = ll, l+1l+1, \ldots, rr;
  2. "| ll rr xx": change a_ia\_i to (a_ia\_i OR xx) for all ii = ll, l+1l+1, \ldots, rr;
  3. "? ll rr": find the minimal value among a_la\_l, a_l+1a\_{l+1}, \ldots, a_ra\_r.

Output the answers for all queries of the third type.

입력

The first line contains one integer nn (1n51051 \le n \le 5 \cdot 10^5) --- the size of the array.

The second line contains nn space-separated integers a_ia\_i (0a_i<2300 \le a\_i < 2^{30}) --- the elements of the array.

The third line contains one integer mm (1m21051 \le m \le 2 \cdot 10^5) --- the number of queries.

Next mm lines contain descriptions of queries in the format described above. For all queries 1lrn1 \le l \le r \le n, for queries of the first and second types 0x<2300 \le x < 2^{30}.

출력

For each query of the third type, print the answer on a separate line.