#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 7;
const long long MAXV = 3 * MAXN;
long long n, m;
long long a[MAXN], b[MAXN];
long long q;
long long t[MAXN], p[MAXN], x[MAXN];
void read() {
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i < m; ++i) {
    cin >> b[i];
  }
  cin >> q;
  for (long long i = 0; i < q; ++i) {
    cin >> t[i];
    if (t[i] <= 2) {
      cin >> p[i] >> x[i];
      --p[i];
    }
  }
}
long long u = 0;
long long v[MAXV];
void compr() {
  for (long long i = 0; i < n; ++i) {
    v[u++] = a[i];
  }
  for (long long i = 0; i < m; ++i) {
    v[u++] = b[i];
  }
  for (long long i = 0; i < q; ++i) {
    if (t[i] <= 2) {
      v[u++] = x[i];
    }
  }
  sort(v, v + u);
  u = unique(v, v + u) - v;
  for (long long i = 0; i < n; ++i) {
    a[i] = lower_bound(v, v + u, a[i]) - v;
  }
  for (long long i = 0; i < m; ++i) {
    b[i] = lower_bound(v, v + u, b[i]) - v;
  }
  for (long long i = 0; i < q; ++i) {
    if (t[i] <= 2) {
      x[i] = lower_bound(v, v + u, x[i]) - v;
    }
  }
}
long long tree[MAXV << 2], add[MAXV << 2];
void push(long long v) {
  tree[v * 2 + 1] += add[v];
  add[v * 2 + 1] += add[v];
  tree[v * 2 + 2] += add[v];
  add[v * 2 + 2] += add[v];
  add[v] = 0;
}
void upd(long long v, long long tl, long long tr, long long l, long long r,
         long long x) {
  if (tr < l || r < tl) {
    return;
  }
  if (l <= tl && tr <= r) {
    tree[v] += x;
    add[v] += x;
    return;
  }
  long long tm = (tl + tr) >> 1;
  push(v);
  upd(v * 2 + 1, tl, tm, l, r, x);
  upd(v * 2 + 2, tm + 1, tr, l, r, x);
  tree[v] = max(tree[v * 2 + 1], tree[v * 2 + 2]);
}
long long get(long long v, long long tl, long long tr) {
  if (tl == tr) {
    return tl;
  }
  long long tm = (tl + tr) >> 1;
  push(v);
  if (tree[v * 2 + 2] >= 1) {
    return get(v * 2 + 2, tm + 1, tr);
  } else {
    return get(v * 2 + 1, tl, tm);
  }
}
void add1(long long x) { upd(0, 0, MAXV, 0, x, 1); }
void del1(long long x) { upd(0, 0, MAXV, 0, x, -1); }
void upd1(long long p, long long x) {
  del1(a[p]);
  a[p] = x;
  add1(a[p]);
}
void add2(long long x) { upd(0, 0, MAXV, 0, x, -1); }
void del2(long long x) { upd(0, 0, MAXV, 0, x, 1); }
void upd2(long long p, long long x) {
  del2(b[p]);
  b[p] = x;
  add2(b[p]);
}
long long get() {
  if (tree[0] >= 1) {
    return get(0, 0, MAXV);
  } else {
    return -1;
  }
}
void solve() {
  compr();
  for (long long i = 0; i < n; ++i) {
    add1(a[i]);
  }
  for (long long i = 0; i < m; ++i) {
    add2(b[i]);
  }
}
void print() {
  for (long long i = 0; i < q; ++i) {
    if (t[i] == 1) {
      upd1(p[i], x[i]);
    } else {
      upd2(p[i], x[i]);
    }
    {
      long long ans = get();
      if (ans == -1) {
        cout << "-1\n";
      } else {
        cout << v[ans] << '\n';
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  read();
  solve();
  print();
  return 0;
}
