#include <bits/stdc++.h>
using namespace std;
struct node {
  int val, lazy;
  node() {
    val = -INT_MAX;
    lazy = 0;
  }
  node(int x, int y) : val(x), lazy(y) {}
};
int N = (int)(1e6) + 1;
vector<node> tree(5 * (N + 100), node());
vector<int> arr(N, 0);
void build(int s, int e, int nid) {
  if (s == e) {
    tree[nid] = node(arr[s], 0);
    return;
  }
  int mid = (s + e) / 2;
  build(s, mid, 2 * nid + 1);
  build(mid + 1, e, 2 * nid + 2);
  tree[nid].val = max(tree[nid * 2 + 1].val, tree[nid * 2 + 2].val);
  tree[nid].lazy = 0;
  return;
}
void resolve_lazy(int nid, int s, int e) {
  if (s != e) {
    tree[nid].val += tree[nid].lazy;
    tree[2 * nid + 1].lazy += tree[nid].lazy;
    tree[2 * nid + 2].lazy += tree[nid].lazy;
    tree[nid].lazy = 0;
  } else {
    tree[nid].val += tree[nid].lazy;
    tree[nid].lazy = 0;
  }
}
void update(int s, int e, int nid, int l, int r, int val) {
  if (tree[nid].lazy != 0) resolve_lazy(nid, s, e);
  if (l <= s && e <= r) {
    tree[nid].lazy += val;
    resolve_lazy(nid, s, e);
    return;
  }
  if (e < l || r < s) return;
  int mid = (s + e) / 2;
  update(s, mid, 2 * nid + 1, l, r, val);
  update(mid + 1, e, 2 * nid + 2, l, r, val);
  tree[nid].val = max(tree[2 * nid + 1].val, tree[2 * nid + 2].val);
  return;
}
int query(int s, int e, int nid) {
  if (tree[nid].lazy != 0) resolve_lazy(nid, s, e);
  if (tree[nid].val <= 0) return -1;
  if (s == e) return s;
  int mid = (s + e) / 2;
  int left = 2 * nid + 1;
  int right = 2 * nid + 2;
  if (tree[left].lazy != 0) resolve_lazy(left, s, e);
  if (tree[right].lazy != 0) resolve_lazy(right, s, e);
  if (tree[right].val > 0)
    return query(mid + 1, e, right);
  else if (tree[left].val > 0)
    return query(s, mid, left);
  else
    return -1;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  vector<int> b(m + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    arr[a[i]]++;
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    arr[b[i]]--;
  }
  for (int i = arr.size() - 2; i >= 0; i--) arr[i] += arr[i + 1];
  build(0, N - 1, 0);
  int q;
  cin >> q;
  int t, i, x;
  while (q--) {
    cin >> t >> i >> x;
    if (t == 1) {
      if (a[i] < x)
        update(0, N - 1, 0, a[i] + 1, x, 1);
      else if (a[i] > x)
        update(0, N - 1, 0, x + 1, a[i], -1);
      a[i] = x;
      cout << query(0, N - 1, 0) << '\n';
    } else {
      if (b[i] < x)
        update(0, N - 1, 0, b[i] + 1, x, -1);
      else if (b[i] > x)
        update(0, N - 1, 0, x + 1, b[i], 1);
      b[i] = x;
      cout << query(0, N - 1, 0) << '\n';
    }
  }
}
