#include <bits/stdc++.h>
using namespace std;
struct Data {
  int op, cl;
  Data(int _op, int _cl) {
    op = _op;
    cl = _cl;
  }
  Data() {}
} tree[4 * 1000000];
int ar[1000000 + 5], br[1000000 + 5];
Data Merge(Data l, Data r) {
  Data res;
  if (l.op >= r.cl) {
    res.cl = l.cl;
    res.op = l.op + r.op - r.cl;
  } else {
    res.op = r.op;
    res.cl = r.cl + l.cl - l.op;
  }
  return res;
}
void update(int node, int b, int e, int idx, Data d) {
  if (idx > e || idx < b) return;
  if (b == e) {
    tree[node].op += d.op;
    tree[node].cl += d.cl;
    if (tree[node].op >= tree[node].cl) {
      tree[node].op -= tree[node].cl;
      tree[node].cl = 0;
    } else {
      tree[node].cl -= tree[node].op;
      tree[node].op = 0;
    }
    return;
  }
  int mid = (b + e) / 2;
  update(2 * node, b, mid, idx, d);
  update(2 * node + 1, mid + 1, e, idx, d);
  tree[node] = Merge(tree[2 * node], tree[2 * node + 1]);
}
int query(int node, int b, int e, int open) {
  if (b == e) return b;
  int mid = (b + e) / 2;
  if (tree[2 * node + 1].op > open)
    return query(2 * node + 1, mid + 1, e, open);
  else
    return query(2 * node, b, mid,
                 open + tree[2 * node + 1].cl - tree[2 * node + 1].op);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    update(1, 1, 1000000, ar[i], Data(1, 0));
  }
  for (int i = 1; i <= m; i++) {
    cin >> br[i];
    update(1, 1, 1000000, br[i], Data(0, 1));
  }
  int q;
  cin >> q;
  while (q--) {
    int id, idx, val;
    cin >> id >> idx >> val;
    if (id == 1) {
      update(1, 1, 1000000, ar[idx], Data(-1, 0));
      ar[idx] = val;
      update(1, 1, 1000000, ar[idx], Data(1, 0));
    } else {
      update(1, 1, 1000000, br[idx], Data(0, -1));
      br[idx] = val;
      update(1, 1, 1000000, br[idx], Data(0, 1));
    }
    if (tree[1].op == 0)
      cout << -1 << "\n";
    else
      cout << query(1, 1, 1000000, 0) << "\n";
  }
  return 0;
}
