import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntPredicate;
import java.util.function.LongPredicate;

public class Main {

    static int N, M;
    static int[] A, B;
    static int Q;
    static int[] T, U, V;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        A = sc.nextIntArray(N);
        B = sc.nextIntArray(M);
        Q = sc.nextInt();
        T = new int[Q];
        U = new int[Q];
        V = new int[Q];
        for (int i = 0; i < Q; i++) {
            T[i] = sc.nextInt();
            U[i] = sc.nextInt()-1;
            V[i] = sc.nextInt();
        }

        PrintWriter pw = new PrintWriter(System.out);
        solve(pw);
        pw.flush();
    }

    static void solve(PrintWriter pw) {
        int MAX = 1_000_000;
        SegTree seg = new SegTree(MAX+1);
        for (int i = 0; i < N; i++) {
            seg.update(0, A[i]+1, 1);
        }
        for (int i = 0; i < M; i++) {
            seg.update(0, B[i]+1, -1);
        }

        for (int i = 0; i < Q; i++) {
            int idx = U[i];
            int next = V[i];
            if( T[i] == 1 ) {
                int curr = A[idx];
                seg.update(0, curr+1, -1);
                seg.update(0, next+1, +1);
                A[idx] = next;

            } else {
                int curr = B[idx];
                seg.update(0, curr+1, +1);
                seg.update(0, next+1, -1);
                B[idx] = next;
            }

            if( seg.max[1] > 0 ) {
                // index == value
                pw.println( seg.rightMostIndex(x -> x > 0) );

            } else {
                pw.println(-1);
            }
        }
    }

    static class SegTree {

        int size;
        long[] add;
        long[] max;

        SegTree(int size) {
            this.size = 1;
            while( this.size < size ) this.size *= 2;
            this.add = new long[this.size*2];
            this.max = new long[this.size*2];
        }

        // [from, to)
        void update(int from, int to, long v) {
            _update(from, to, 1, 0, size, v);
        }

        void _update(int from, int to, int idx, int l, int r, long v) {
            if (from <= l && r <= to) {
                add[idx] += v;
                max[idx] += v;
                return;
            }

            int mid = (l+r)/2;
            propagate(idx);
            if (from < mid) _update(from, to, idx*2, l, mid, v);
            if (mid < to) _update(from, to, idx*2+1, mid, r, v);
            max[idx] = Math.max(max[idx*2], max[idx*2+1]);
        }

        void propagate(int idx) {
            long v = add[idx];
            add[idx*2] += v;
            max[idx*2] += v;
            add[idx*2+1] += v;
            max[idx*2+1] += v;
            add[idx] = 0;
        }

        int rightMostIndex(LongPredicate p) {
            if( p.test(max[1]) ) {
                return _rightMostIndex(0, size, 1, p);
            } else {
                return -1;
            }
        }

        int _rightMostIndex(int l, int r, int idx, LongPredicate p) {
            if( r - l == 1 ) return l;

            int mid = (l+r)/2;
            propagate(idx);

            // test right-side first
            if( p.test(max[idx*2+1]) ) {
                return _rightMostIndex(mid, r, idx*2+1, p);
            } else {
                return _rightMostIndex(l, mid, idx*2, p);
            }
        }
    }

    static int maximize(int lo, int hi, IntPredicate p) {
        while(lo < hi) {
            int x = ((hi - lo) >>> 1) + lo;
            if( p.test(x) ) {
                lo = x + 1;
            } else {
                hi = x;
            }
        }
        return lo - 1;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static void writeSingleLine(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < as.length; i++) {
            if (i != 0) pw.print(" ");
            pw.print(as[i]);
        }
        pw.println();
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg == null) j.add("null");
            else if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }

    static void printSingleLine(int[] array) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < array.length; i++) {
            if (i != 0) pw.print(" ");
            pw.print(array[i]);
        }
        pw.println();
        pw.flush();
    }

    static int lowerBound(int[] array, int value) {
        int lo = 0, hi = array.length, mid;
        while (lo < hi) {
            mid = (hi + lo) / 2;
            if (array[mid] < value) lo = mid + 1;
            else hi = mid;
        }
        return lo;
    }

    static int upperBound(int[] array, int value) {
        int lo = 0, hi = array.length, mid;
        while (lo < hi) {
            mid = (hi + lo) / 2;
            if (array[mid] <= value) lo = mid + 1;
            else hi = mid;
        }
        return lo;
    }
}
