#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/




int N, A[201010], B[201010], Q;
//--------------------------------------------------------------------------------------------------
#define INF INT_MAX/2
int S, Ami[1010], Bmi[1010];
int AorB[1010]; // -1:none 0:A 1:B
void update(int s) {
    int L = s * S, R = (s + 1) * S;

    Ami[s] = Bmi[s] = INF;
    rep(i, L, R) if (i < N) {
        Ami[s] = min(Ami[s], A[i]);
        Bmi[s] = min(Bmi[s], B[i]);
    }
}
void lazy(int s) {
    int L = s * S, R = (s + 1) * S;

    if (AorB[s] == 0) {
        rep(i, L, R) if (i < N) B[i] = A[i];
        AorB[s] = -1;
    }
    if(AorB[s] == 1) {
        rep(i, L, R) if (i < N) A[i] = B[i];
        AorB[s] = -1;
    }
}
void init() {
    S = sqrt(N);
    rep(i, 0, N / S + 1) update(i);
    rep(i, 0, N / S + 1) AorB[i] = -1;
}
//--------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];

    init();

    cin >> Q;
    rep(i, 0, Q) {
        int x, y, z; cin >> x >> y >> z;

        if (x == 1) {
            y--;
            int s = y / S;
            lazy(s);
            A[y] = z;
            update(s);
        }

        if (x == 2) {
            y--;
            int s = y / S;
            lazy(s);
            B[y] = z;
            update(s);
        }

        if (x == 3) {
            y--;

            int ans = INF;
            rep(i, 0, N / S + 1) {
                int a = i * S, b = (i + 1) * S;
                if (y <= a && b <= z) {
                    if (AorB[i] == 1) ans = min(ans, Bmi[i]);
                    else ans = min(ans, Ami[i]);
                }
                else {
                    if (max(a, y) < min(b, z)) {
                        lazy(i);
                        update(i);
                        rep(j, max(a, y), min(b, z)) ans = min(ans, A[j]);
                    }
                }
            }

            printf("%d\n", ans);
        }

        if (x == 4) {
            y--;

            int ans = INF;
            rep(i, 0, N / S + 1) {
                int a = i * S, b = (i + 1) * S;
                if (y <= a && b <= z) {
                    if (AorB[i] == 0) ans = min(ans, Ami[i]);
                    else ans = min(ans, Bmi[i]);
                }
                else {
                    if (max(a, y) < min(b, z)) {
                        lazy(i);
                        update(i);
                        rep(j, max(a, y), min(b, z)) ans = min(ans, B[j]);
                    }
                }
            }

            printf("%d\n", ans);
        }

        if (x == 5) {
            rep(i, 0, N / S + 1) if (AorB[i] != 0) AorB[i] = 1;
        }

        if (x == 6) {
            rep(i, 0, N / S + 1) if (AorB[i] != 1) AorB[i] = 0;
        }
    }
}

Measured memory_bytes: 4824