#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
struct A
{
	int l,r;
	int nxl,nxr;
	int small;
	int con;
	int tag;
}Node[8000005];
int a[100005];
int b[100005];
int now=1;
void build(int l,int r,int here)
{
    //printf("%d %d\n",l,r);
	Node[here].l=l;
	Node[here].r=r;
	Node[here].con=0;
	Node[here].small=0;
	if(l==r) return;
	Node[here].nxl=now++;
	Node[here].nxr=now++;
	build(l,(l+r)/2,Node[here].nxl);
	build((l+r)/2+1,r,Node[here].nxr);
}
void update(int here)
{
	Node[Node[here].nxl].small+=Node[here].tag;
	Node[Node[here].nxl].tag+=Node[here].tag;
	Node[Node[here].nxr].small+=Node[here].tag;
	Node[Node[here].nxr].tag+=Node[here].tag;
	Node[here].tag=0;
}
void change(int l,int r,int ch,int here)
{
	if(Node[here].l==l&&Node[here].r==r)
	{
		Node[here].small+=ch;
		Node[here].tag+=ch;
		return;
	}
	update(here);
	if(r<=(Node[here].l+Node[here].r)/2) change(l,r,ch,Node[here].nxl);
	else if(l>(Node[here].l+Node[here].r)/2) change(l,r,ch,Node[here].nxr);
	else 
	{
		change(l,(Node[here].l+Node[here].r)/2,ch,Node[here].nxl);
		change((Node[here].l+Node[here].r)/2+1,r,ch,Node[here].nxr);

	}
	Node[here].small=min(Node[Node[here].nxl].small,Node[Node[here].nxr].small);
	//printf("%d %d %d\n",Node[here].l,Node[here].r,Node[here].small);
}
int Find(int here)
{
	if(Node[here].small>=0) return -1;
	if(Node[here].l==Node[here].r) return Node[here].l;
	update(here);
	if(Node[Node[here].nxr].small<0) Find(Node[here].nxr);
	else Find(Node[here].nxl);
}
int main()
{
	int N,M,i,j,k,ok=0,x,y,z;
	scanf("%d %d",&N,&M);
	build(0,1500000,0);
	for(i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
		change(0,a[i],0,-1);
	}
	for(i=0;i<M;i++)
	{
		scanf("%d",&b[i]);
		change(0,b[i],0,1);
	}
	scanf("%d",&M);
	while(M--)
	{
		scanf("%d %d %d",&x,&y,&z);
		y--;
		if(x==1)
		{
			change(0,a[y],0,1);
			change(0,z,0,-1);
			a[y]=z;
		}
		else 
		{
			change(0,b[y],0,-1);
			change(0,z,0,1);
			b[y]=z;
		}
		printf("%d\n",Find(0));
	}
	return 0;

}