#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 7340033;
const double eps = 1e-8;
const double PI = acos(-1);
template <class T, class S>
inline void add(T &a, S b) {
  a += b;
  if (a >= mod) a -= mod;
}
template <class T, class S>
inline void sub(T &a, S b) {
  a -= b;
  if (a < 0) a += mod;
}
template <class T, class S>
inline bool chkmax(T &a, S b) {
  return a < b ? a = b, true : false;
}
template <class T, class S>
inline bool chkmin(T &a, S b) {
  return a > b ? a = b, true : false;
}
int n, m, a[N], b[N];
const int maxVal = 1000000;
struct segmentTree {
  int lazy[N << 2], mx[N << 2];
  inline void pull(int rt) { mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]); }
  inline void push(int rt) {
    if (lazy[rt]) {
      lazy[rt << 1] += lazy[rt];
      lazy[rt << 1 | 1] += lazy[rt];
      mx[rt << 1] += lazy[rt];
      mx[rt << 1 | 1] += lazy[rt];
      lazy[rt] = 0;
    }
  }
  void update(int L, int R, int val, int l = 1, int r = maxVal, int rt = 1) {
    if (R < l || r < L || R < L) return;
    if (L <= l && r <= R) {
      mx[rt] += val;
      lazy[rt] += val;
      return;
    }
    push(rt);
    int mid = l + r >> 1;
    update(L, R, val, l, mid, rt << 1);
    update(L, R, val, mid + 1, r, rt << 1 | 1);
    pull(rt);
  }
  int query(int l = 1, int r = maxVal, int rt = 1) {
    if (mx[rt] <= 0) return -1;
    if (l == r) return l;
    push(rt);
    int mid = l + r >> 1;
    if (mx[rt << 1 | 1] > 0)
      return query(mid + 1, r, rt << 1 | 1);
    else
      return query(l, mid, rt << 1);
  }
} Tree;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) {
    Tree.update(1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    Tree.update(1, b[i], -1);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int op, p, x;
    scanf("%d%d%d", &op, &p, &x);
    if (op == 1) {
      Tree.update(1, a[p], -1);
      a[p] = x;
      Tree.update(1, a[p], 1);
    } else {
      Tree.update(1, b[p], 1);
      b[p] = x;
      Tree.update(1, b[p], -1);
    }
    printf("%d\n", Tree.query());
  }
  return 0;
}
