#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int nn = 3e5 +5;

#define MAXN 1000005
#define left(i) (2 * (i) + 1)
#define right(i) (2 * (i) + 2)
#define parent(i) (((i) - 1) / 2)

const int logmaxn = (int) log2(MAXN) + 1;
const int ts = 1 << (logmaxn + 1), to = (1 << logmaxn) - 1;

// the data with default values
struct data {
  int v = 0;
};

// the operation with default values
// this default operation applies a * v + b to every element v
struct operation {
  int v = 0;
};

int n, a[MAXN];
data t[ts];
operation o[ts];

// combine the data from different branches
data combine(data l, data r) {
  return {max(l.v, r.v)};
}

// apply an operation on top of an other operation
operation combine(operation ot, operation ob) {
  return {ot.v + ob.v};
}

// apply an operation on a range with data
data apply(operation ot, data d) {
  return {ot.v + d.v};
}

data getValue(int x) {
  return apply(o[x], t[x]);
}

void calcValue(int x) {
  t[x] = combine(getValue(left(x)), getValue(right(x)));
}

void propagate(int x) {
  o[left(x)] = combine(o[x], o[left(x)]);
  o[right(x)] = combine(o[x], o[right(x)]);
  o[x] = operation();
}

int query1(int x = 0, int l = 0, int r = (1 << logmaxn) - 1) {
	//cerr << "query1 x:" << x << " l : " << l  << " x: " << r << endl;
  if (l == r)
    return l;
  int m = (l + r) / 2;
  propagate(x);
  if(getValue(right(x)).v > 0){
  	return query1(right(x), m+1, r);
  }else if (getValue(left(x)).v > 0){
  	return query1(left(x), l, m);
  }
  return -1;
}

// apply an operation on the range [a, b[
void apply(int a, int b, operation v, int x = 0, int l = 0, int r = 1 << logmaxn) {
  if (a <= l && r <= b) {
    o[x] = combine(v, o[x]);
    return;
  }
  if (b <= l || r <= a)
    return;
  int m = (l + r) / 2;
  propagate(x);
  apply(a, b, v, left(x), l, m);
  apply(a, b, v, right(x), m, r);
  calcValue(x);
}

// get the data for the i-th position
data getData(int i) {
  if (i < n)
    return {a[i]};
  else
    return {0};
}

void init() {
  for (int i = 0; i < (1 << logmaxn); i++)
    t[to + i] = getData(i);
  for (int x = to - 1; x >= 0; x--)
    calcValue(x);
}


int N, M, Q;
int A[nn], B[nn];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> M;
	n = MAXN;
	init();

	for(int i = 0; i < N; ++i){
		cin >> A[i];
		apply(0, A[i]+1, {1});
	}
	for(int i = 0; i < M; ++i){
		cin >> B[i];
		apply(0, B[i]+1, {-1});
	}
	cin >> Q;
	for(int i = 0; i < Q; ++i){
		int t,j, x; cin >> t >> j >> x;
		j--;
		if(t == 1){ // dish update
			apply(0, A[j]+1, {-1});
			apply(0, x+1, {1});
			A[j] = x;
		}else{ //student update
			apply(0, B[j]+1, {+1});
			apply(0, x+1, {-1});
			B[j] = x;
		}
		//cerr << "max: " << query(0, MAXN).v << endl;
		int y = query1();
		cout << y << "\n";
	}
	
	return 0;
}
