#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int maxm = 3e5 + 5;
const long long inf = 998244353;
long long n, m;
long long sum[maxn << 2];
int tz[maxn << 2];
int fid[maxm], cid[maxm];
inline void pushDown(int x) {
  if (tz[x]) {
    tz[x << 1] += tz[x];
    tz[x << 1 | 1] += tz[x];
    sum[x << 1] += tz[x];
    sum[x << 1 | 1] += tz[x];
    sum[x] = max(sum[x << 1], sum[x << 1 | 1]);
    tz[x] = 0;
  }
}
inline int findAnswer(int l, int r, int x) {
  if (l == r) {
    if (sum[x] > 0)
      return r;
    else
      return -1;
  }
  pushDown(x);
  int mid = (l + r) >> 1;
  if (sum[x << 1 | 1] > 0) {
    return findAnswer(mid + 1, r, x << 1 | 1);
  } else if (sum[x << 1] > 0) {
    return findAnswer(l, mid, x << 1);
  } else
    return -1;
}
inline void update(int l, int r, int L, int R, int x, int v) {
  if (L >= l && r >= R) {
    tz[x] += v;
    sum[x] += v;
    return;
  }
  pushDown(x);
  int mid = (L + R) >> 1;
  if (mid >= l) {
    update(l, r, L, mid, x << 1, v);
  }
  if (mid < r) {
    update(l, r, mid + 1, R, x << 1 | 1, v);
  }
  sum[x] = max(sum[x << 1], sum[x << 1 | 1]);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &fid[i]);
    update(1, fid[i], 1, 1e6, 1, 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &cid[i]);
    update(1, cid[i], 1, 1e6, 1, -1);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == 1) {
      update(1, fid[b], 1, 1e6, 1, -1);
      update(1, c, 1, 1e6, 1, 1);
      fid[b] = c;
    } else {
      update(1, cid[b], 1, 1e6, 1, 1);
      update(1, c, 1, 1e6, 1, -1);
      cid[b] = c;
    }
    int ans = findAnswer(1, 1e6, 1);
    printf("%d\n", ans);
  }
  return 0;
}
