import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;


public class q5 {
	
	public static void main(String[] args) throws IOException {
		
		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt(),m=Reader.nextInt();
		int high=(int)1e6+1;
		Seg tree=new Seg(high);
		int[] arr1=new int[n];
		int[] arr2=new int[m];
		for(int i=0;i<n;i++) {
			arr1[i]=Reader.nextInt();
			tree.update(0, 0, high-1, 0, arr1[i], -1);
		}
		for(int i=0;i<m;i++) {
			arr2[i]=Reader.nextInt();
			tree.update(0, 0, high-1, 0, arr2[i], 1);
		}
		int q=Reader.nextInt();
		while(q>0) {
			q--;
			int a=Reader.nextInt(),b=Reader.nextInt(),c=Reader.nextInt();
			if(a==1) {
				tree.update(0, 0, high-1, 0, arr1[b-1], 1);
				arr1[b-1]=c;
				tree.update(0, 0, high-1, 0, c, -1);
			}
			else {
				tree.update(0, 0, high-1, 0, arr2[b-1], -1);
				arr2[b-1]=c;
				tree.update(0, 0, high-1, 0, c, 1);
			}
			out.println(tree.query(0, 0, high-1));
		}
		
		out.flush();
		
	}
}

class Seg{
	
	int[] st,lazy;
	Seg(int n){
		st=new int[4*n];
		lazy=new int[4*n];
	}
	void push(int index,int left, int right) {
		st[index]+=lazy[index];
		if(left!=right) {
			lazy[2*index+1]+=lazy[index];
			lazy[2*index+2]+=lazy[index];
		}
		lazy[index]=0;
	}
	int query(int index,int left, int right) {
		push(index,left,right);
		if(st[index]>=0) {
			return -1;
		}
		
		if(left==right) {
			if(left==0) return -1;
			return left;
		}
		
		int mid=(left+right)/2;
		int a= query(2*index+2,mid+1,right);
		
		if(a==-1) a= query(2*index+1,left,mid);
		
		st[index]=Math.min(st[2*index+1], st[2*index+2]);
		return a;
	}
	
	void update(int index, int left, int right, int ql, int qr, int val) {
		push(index,left,right);
		if(ql<=left && right<=qr) {
			lazy[index]+=val;
			push(index,left,right);
			return;
		}
		if(ql>right || qr<left) return ;
		
			int mid=(left+right)/2;
			update(2*index+1,left,mid,ql,qr,val);
			update(2*index+2,mid+1,right,ql,qr,val);
			st[index]=Math.min(st[2*index+1], st[2*index+2]);
		
	}
}



class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}