#include <iostream>
#include <bitset>
#include <cmath>
#include <stack>

void show(unsigned long long* A, int n, int m)
{
	for (int i=0; i<n; i++) {
		std::cout << A[i] << ", ";
		if (i%m==m-1) std::cout << std::endl;
	}
	std::cout << std::endl;
}

void showST(int** ST, int n, int m)
{
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) std::cout << ST[i][j] << " ";
		std::cout << std::endl;
	}
}

void showBS(std::bitset<8>** l, int m, int k, int n)
{
	for (int i=0; i<k-1; i++) {
		std::cout << i << ": ";
		for (int j=0; j<m; j++) std::cout << l[i][j].to_ulong() << ", ";
		std::cout << std::endl;
	}
	
	int size = n - (k-1)*m;
	std::cout << k-1 << ": ";
	for (int j=0; j<size; j++) std::cout << l[k-1][j].to_ulong() << ", ";
	std::cout << std::endl;
}

int min(int x, int y)
{
	return x>y ? y : x;
}

int max(int x, int y)
{
	return x>y ? x : y;
}

/* construct sparse table */
void constructST(int** ST, unsigned long long* A, int n)
{
	int m = (int)(log2((float)n)) + 1; // range of p, second subscript of ST[i][p]
	
	for (int i=0; i<n; i++) ST[i][0] = i;
	
	for (int p=1; p<m; p++) {
		for (int i=0; i<n; i++) {
			int q = min(i + (1<<(p-1)), n-1);
			if (A[ST[i][p-1]] < A[ST[q][p-1]]) ST[i][p] = ST[i][p-1];
			else ST[i][p] = ST[q][p-1];
		}
	}
}

void updateST(int** ST, unsigned long long* A, int index, int n)
{
	int m = (int)(log2((float)n)) + 1; // range of p, second subscript of ST[i][p]
	
	for (int p=1; p<m; p++) {
		int start = max(0, index-(1<<p)+1);
		for (int i=start; i<=index; i++) {
			int q = min(i + (1<<(p-1)), n-1);
			if (A[ST[i][p-1]] < A[ST[q][p-1]]) ST[i][p] = ST[i][p-1];
			else ST[i][p] = ST[q][p-1];
		}
	}
}

/* range minimum query for sparse table */
int rmqST(unsigned long long* M, int** ST, int i, int j)
{
	if (i==j) return ST[i][0];
	int p = abs((int)log2((float)(j-i)));
	if (M[ST[i][p]] < M[ST[j-(1<<p)+1][p]]) return ST[i][p];
	else return ST[j-(1<<p)+1][p];
}

void calcBitSequence(unsigned long long* B, std::bitset<8>* l, int m)
{
	int* g = new int[m];
	
	for (int i=0; i<m; i++) g[i] = i-1;
	
	std::stack<int> st;
	
	// calculate g[0..m-1]
	for (int i=m-1; i>=0; i--) {
		while (!st.empty() && B[i] < B[st.top()]) {
			g[st.top()] = i; st.pop();
		}
		if (i>0 && B[i-1] > B[i]) st.push(i);
	}
	while (!st.empty()) {
		g[st.top()] = -1; st.pop();
	}
	
	// calculate bit sequence l[0], ..., l[m-1]
	// assumption : l[i] is resized by m 
	for (int j=1; j<m; j++) {
		if (g[j] >= 0) {
			l[j] = l[g[j]];
			l[j].set(g[j]);
		}
		else l[j].reset();
	}
	
	delete[] g;
}

int rmqBS(std::bitset<8>* l, int m, int i, int j)
{
	std::bitset<8> mask(256-(1<<i));
	std::bitset<8> tmp = mask & l[j];
	if (tmp.none()) return j;
	else {
		for (int k=0; k<m; k++) {
			if (tmp.test(k)) return k;
		}
	}
}

bool isSameBlock(int i, int j, int m)
{
	return i/m == j/m;
}

// * this function returns the minimum value! (not its index)
unsigned long long rmq(unsigned long long* A, std::bitset<8>** l, int m, unsigned long long* M, int** ST, int k, int i, int j)
{
	if (isSameBlock(i, j, m)) {
		int res_bs = i - i%m + rmqBS(l[i/m], m, i%m ,j%m);
		//std::cout << "  rmqBS(" << i/m << "," << m << "," << i%m << "," << j%m << ") : res_bs = " << res_bs << std::endl;
		return A[res_bs];
	}
	
	int el = -1;
	for (; el < i; el+=m);
	int sr = (k-1)*m;
	for (; sr > j; sr -= m);
	int left = (el+1) / m;
	int right = sr/m - 1;
	
	int res_bs1 = m * (left-1) + rmqBS(l[left-1], m, i%m, el%m);
	//std::cout << "  rmqBS(" << left-1 << "," << m << "," << i%m << "," << el%m << ") : res_bs1 = " << res_bs1 << std::endl;
	int res_bs2 = m * (right+1) + rmqBS(l[right+1], m, sr%m, j%m);
	//std::cout << "  rmqBS(" << right+1 << "," << m << "," << sr%m << "," << j%m << ") : res_bs2 = " << res_bs2 << std::endl;
	if (left <= right) {
		int res_st = rmqST(M, ST, left, right);
		//std::cout << "  rmqST(" << left << "," << right << ") = " << res_st << std::endl;
		if (A[res_bs1] <= A[res_bs2]) {
			if (A[res_bs1] <= M[res_st]) return A[res_bs1];
			else return M[res_st];
		} else {
			if (A[res_bs2] <= M[res_st]) return A[res_bs2];
			else return M[res_st];
		}
	}
	else {
		return min(A[res_bs1], A[res_bs2]);
	}
	
}

void process(unsigned long long* A, std::bitset<8>** l, int m, unsigned long long* M, int** ST, int k, int n)
{
	for (int i=0; i<k; i++) {
		int size = (i<k-1) ? m : n%m;
		if (size==0) size = m;
		int offset = m*i;
		calcBitSequence(A + offset, l[i], size);
		M[i] = A[offset + rmqBS(l[i], m, 0, size-1)];
	}
	
	constructST(ST, M, k);
}

void update(unsigned long long* A, int i, std::bitset<8>** l, int m, unsigned long long* M, int** ST, int k, int n)
{
	int block_index = i/m;
	int offset = m * block_index;
	calcBitSequence(A + offset, l[block_index], m);
	int size;
	if (block_index < k-1) size = m;
	else size = n - m*(k-1);
	unsigned long long value = A[offset + rmqBS(l[block_index], m, 0, size-1)];
	if (value != M[block_index]) {
		M[block_index] = value;
		updateST(ST, M, block_index, k);
	}
}
	
int main()
{	
	int n; std::cin >> n;
	unsigned long long* A = new unsigned long long[n];
	std::bitset<31> bs_tmp(0);
	bs_tmp.set();
	for (int i=0; i<n; i++) A[i] = bs_tmp.to_ullong();
	
	int m = (int)(log2((float)n) / 2) + 1; // size of a block of A
	int k = (n%m==0) ? n/m : n/m + 1; // number of blocks of A
	
	//std::cout << "m = " << m << ", k = " << k << std::endl;
	
	unsigned long long* M = new unsigned long long[k];
	int** ST = new int*[k];
	int m_ = (int)(log2((float)k)) + 1;
	for (int i=0; i<k; i++) ST[i] = new int[m_];
	
	std::bitset<8>** l = new std::bitset<8>*[k];
	for (int i=0; i<k; i++) l[i] = new std::bitset<8>[m];
	
	process(A, l, m, M, ST, k, n);
	// std::cout << "A : "; show(A, n);
	
	int q; std::cin >> q;
	int output_count = 0;
	bool update_finished = false;
	for (int i=0; i<q; i++) {
		//if (output_count==30) break;
		//std::cout << "loop : " << i << std::endl;
		int op, x, left, right;
		unsigned long long y;
		std::cin >> op;
		if (op==0) {
			std::cin >> x >> y;
			A[x] = y;
			update(A, x, l, m, M, ST, k, n);
		} else {
			
			
			//std::cout << "A : "; show(A, n, m);
			//std::cout << "M : "; show(M, k, 5);
			//std::cout << "ST : " << std::endl; showST(ST, k, m_);
			//std::cout << "l : " << std::endl; showBS(l, m, k, n);
			
			
			std::cin >> left >> right;
			//std::cout << std::endl << ++output_count << " (" << left << ", " << right << ") : " << std::endl;
			int res = rmq(A, l, m, M, ST, k, left, right);
			//std::cout << ++output_count << " : ";
			std::cout << res << std::endl;
		}
	}
	
	delete[] A;
	delete[] M;
	for (int i=0; i<k; i++) delete[] ST[i];
	delete[] ST;
	for (int i=0; i<k; i++) delete[] l[i];
	delete[] l;
	
	return 0;
}



Measured memory_bytes: 5576