#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5, K = 1e6 + 5;
inline long long readi() {
  long long x;
  return scanf("%lld", &x), x;
}
int n, m, q, a[N], b[N];
long long cnt[K];
struct Data {
  long long s1, s2;
  Data(long long s1 = 0, long long s2 = 0) : s1(s1), s2(s2) {}
};
Data merge(Data x, Data y) { return Data(x.s1 + y.s1, max(x.s2 + y.s1, y.s2)); }
struct SegTree {
  Data d[4 * K];
  int n;
  void update(long long x, int p, int s, int t) { d[p] = Data(x, max(x, 0LL)); }
  void build(long long *a, int p, int s, int t) {
    d[p] = s != t ? build(a, (p << 1), s, ((s + t) >> 1)),
    build(a, (p << 1 | 1), ((s + t) >> 1) + 1, t),
    merge(d[(p << 1)], d[(p << 1 | 1)]) : Data(a[s], max(a[s], 0LL));
  }
  void build(long long *a, int tot) { n = tot, build(a, 1, 1, n); }
  void update(int x, long long y, int p, int s, int t) {
    if (x == s && x == t) return update(y, p, s, t);
    x <= ((s + t) >> 1) ? update(x, y, (p << 1), s, ((s + t) >> 1))
                        : update(x, y, (p << 1 | 1), ((s + t) >> 1) + 1, t),
        d[p] = merge(d[(p << 1)], d[(p << 1 | 1)]);
  }
  void update(int x, long long y) { update(x, y, 1, 1, n); }
  int solve() {
    if (d[1].s2 <= 0) return -1;
    int p = 1, s = 1, t = n;
    long long sum = 0;
    while (s < t)
      d[(p << 1 | 1)].s2 + sum > 0
          ? (s = ((s + t) >> 1) + 1, p = (p << 1 | 1))
          : (t = ((s + t) >> 1), sum += d[(p << 1 | 1)].s1, p = (p << 1));
    return s;
  }
} sol;
int main() {
  n = readi(), m = readi();
  for (int i = 1; i <= n; ++i) ++cnt[a[i] = readi()];
  for (int i = 1; i <= m; ++i) --cnt[b[i] = readi()];
  sol.build(cnt, K - 1), q = readi();
  for (int i = 1; i <= q; ++i) {
    int op = readi(), x = readi(), y = readi();
    if (op == 1)
      sol.update(a[x], --cnt[a[x]]), a[x] = y, sol.update(a[x], ++cnt[a[x]]);
    else
      sol.update(b[x], ++cnt[b[x]]), b[x] = y, sol.update(b[x], --cnt[b[x]]);
    printf("%d\n", sol.solve());
  }
  return 0;
}
