import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	static final int MAXN = 1000005;
	static int[] f = new int[MAXN * 4];
	static int[] lz = new int[MAXN * 4];
	static int n, m;
	static int[] a = new int[300005];
	static int[] b = new int[300005];
	
	static void push(int x, int l, int r) 
	{
	
		if(lz[x] == 0)
			return;
		f[x] += lz[x];
		if(l != r) {
			lz[x * 2] += lz[x];
			lz[x * 2 + 1] += lz[x];
		}
		lz[x] = 0;
	
	}
	
	static void update(int x, int l, int r, int ll, int rr, int val) 
	{
		push(x, l, r);
		if(l > rr || r < ll)
			return;
		if(l >= ll && r <= rr) {
			lz[x] += val;
			push(x, l, r);
			return;
		}
		int md = (l + r) / 2;
		update(x * 2, l, md, ll, rr, val);
		update(x * 2 + 1, md + 1, r, ll, rr, val);
		f[x] = Math.min(f[x * 2], f[x * 2 + 1]);
	
	}
	
	static int query(int x, int l, int r) 
	{
		push(x, l, r);
	
		if(f[x] >= 0)
			return -1;
		if(l == r) return l;
		int md = (l + r) / 2;
		int rx = query(x * 2 + 1, md + 1, r);
		if(rx != -1)
			return rx;
		return query(x * 2, l, md);
	
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		
		n = in.nextInt();
		m = in.nextInt();
		
		for(int i = 1; i <= n; i++)
		{
			a[i] = in.nextInt();
			update(1, 1, MAXN - 1, 1, a[i], -1);
		}
		
		for(int i = 1; i <= m; i++)
		{
			b[i] = in.nextInt();
			update(1, 1, MAXN - 1, 1, b[i], 1);
		}
		
		int q;
		int q1;
		int q2;
		int q3;
		q = in.nextInt();
		while(q-- > 0)
		{
			q1 = in.nextInt();
			q2 = in.nextInt();
			q3 = in.nextInt();
			if(q1 == 1)
			{
				update(1, 1, MAXN - 1, 1, a[q2], 1);
				a[q2] = q3;
				update(1, 1, MAXN - 1, 1, a[q2], -1);
			}
			else
			{
				update(1, 1, MAXN - 1, 1, b[q2], -1);
				b[q2] = q3;
				update(1, 1, MAXN - 1, 1, b[q2], 1);
			}
			
			out.println(query(1, 1, MAXN - 1));
		}
		
		out.close();
	}
	
	static class InputReader
	{
		BufferedReader reader;
		StringTokenizer tokenizer;
 
		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
 
		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}
 
			return tokenizer.nextToken();
		}
 
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
 
		public long nextLong()
		{
			return Long.parseLong(next());
		}
	}
}