#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
struct node {
  int l, r;
  int sum, mx;
} tr[N << 2];
int a[N], b[N];
void build(int u, int l, int r) {
  if (l == r) {
    tr[u] = {l, r, 0};
    return;
  }
  int mid = l + r >> 1;
  tr[u] = {l, r, 0};
  build(u << 1, l, mid);
  build(u << 1 | 1, mid + 1, r);
}
void push_up(int u) {
  tr[u].sum = tr[u << 1].sum + tr[u << 1 | 1].sum;
  tr[u].mx = max(tr[u << 1 | 1].mx, tr[u << 1].mx + tr[u << 1 | 1].sum);
}
void update(int u, int x, int num) {
  if (tr[u].l == tr[u].r) {
    tr[u].sum += num;
    tr[u].mx = tr[u].sum;
    return;
  }
  int mid = tr[u].l + tr[u].r >> 1;
  if (x <= mid)
    update(u << 1, x, num);
  else
    update(u << 1 | 1, x, num);
  push_up(u);
}
int query(int u, int sum) {
  if (tr[u].l == tr[u].r) {
    return tr[u].l;
  }
  int mid = tr[u].l + tr[u].r >> 1;
  if (sum + tr[u << 1 | 1].mx > 0)
    return query(u << 1 | 1, sum);
  else
    return query(u << 1, sum + tr[u << 1 | 1].sum);
}
void solve() {
  int n, m;
  cin >> n >> m;
  build(1, 1, 1000000);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    update(1, b[i], -1);
  }
  int q;
  cin >> q;
  while (q--) {
    int op, i, x;
    scanf("%d%d%d", &op, &i, &x);
    if (op == 1) {
      update(1, a[i], -1);
      a[i] = x;
      update(1, a[i], 1);
    } else {
      update(1, b[i], 1);
      b[i] = x;
      update(1, b[i], -1);
    }
    if (tr[1].mx <= 0)
      puts("-1");
    else
      printf("%d\n", query(1, 0));
  }
}
int main() {
  solve();
  return 0;
}
