#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const double PI = 3.14159265358979323846264338f;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const long long mod = (int)1e9 + 7;
const int MAXN = 1000005;
inline int read() {
  int c = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    c = c * 10 + ch - '0';
    ch = getchar();
  }
  return c * f;
}
struct SegmentTree {
  int l, r;
  int suf, sum;
} t[MAXN << 2];
int n, m;
int a[MAXN], b[MAXN];
void Build(int l, int r, int rt) {
  t[rt].l = l, t[rt].r = r;
  if (l == r) {
    t[rt].suf = 0;
    t[rt].sum = 0;
    return;
  }
  int mid = (l + r) >> 1;
  Build(l, mid, rt << 1);
  Build(mid + 1, r, rt << 1 | 1);
}
void update(int rt, int val, int flag) {
  if (t[rt].l == t[rt].r) {
    t[rt].sum += val;
    t[rt].suf += val;
    return;
  }
  int mid = (t[rt].l + t[rt].r) >> 1;
  if (flag <= mid)
    update(rt << 1, val, flag);
  else
    update(rt << 1 | 1, val, flag);
  t[rt].sum = t[rt << 1].sum + t[rt << 1 | 1].sum;
  t[rt].suf = max(t[rt << 1].suf + t[rt << 1 | 1].sum, t[rt << 1 | 1].suf);
}
int ask(int rt, pair<int, int> tmp) {
  if (t[rt].l == t[rt].r) {
    return t[rt].l;
  }
  pair<int, int> c(0, 0);
  c.first = tmp.first + t[rt << 1 | 1].sum;
  c.second = t[rt << 1 | 1].suf + tmp.first;
  if (c.second > 0) {
    return ask(rt << 1 | 1, tmp);
  } else {
    return ask(rt << 1, c);
  }
}
void ff(int rt) {
  if (t[rt].l == t[rt].r) {
    return;
  }
  int mid = (t[rt].l + t[rt].r) >> 1;
  ff(rt << 1);
  ff(rt << 1 | 1);
  return;
}
int main() {
  n = read(), m = read();
  Build(1, 1000001, 1);
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    update(1, 1, a[i]);
  }
  for (int i = 1; i <= m; i++) {
    b[i] = read();
    update(1, -1, b[i]);
  }
  int q = read();
  while (q--) {
    int op, pos, v;
    op = read(), pos = read(), v = read();
    if (op == 1) {
      update(1, -1, a[pos]);
      a[pos] = v;
      update(1, 1, a[pos]);
    } else {
      update(1, 1, b[pos]);
      b[pos] = v;
      update(1, -1, b[pos]);
    }
    if (t[1].suf <= 0) {
      printf("-1\n");
    } else {
      printf("%d\n", ask(1, pair<int, int>(0, 0)));
    }
  }
  return 0;
}
