#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, val, lazy;
  node *lnode, *rnode;
  node(int l, int r) : l(l), r(r), val(0), lazy(0) {
    if (r - l == 1) {
      lnode = NULL;
      rnode = NULL;
    } else {
      lnode = new node(l, l + r >> 1);
      rnode = new node(l + r >> 1, r);
    }
  }
  void propagate() {
    if (r - l != 1) {
      lnode->lazy += lazy;
      rnode->lazy += lazy;
    }
    val += lazy;
    lazy = 0;
  }
  void update(int i, int delta) {
    if (l >= i)
      propagate();
    else if (r > i) {
      propagate();
      lnode->update(i, delta);
      rnode->update(i, delta);
      val = max(lnode->val, rnode->val);
    } else {
      lazy += delta;
      propagate();
    }
  }
  int query() {
    if (val <= 0) return -1;
    if (r - l == 1) return r;
    lnode->propagate();
    rnode->propagate();
    if (rnode->val > 0)
      return rnode->query();
    else
      return lnode->query();
  }
};
node* tree = new node(0, 1000000);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int price[n];
  int money[m];
  for (int i = 0; i != n; ++i) {
    int x;
    cin >> x;
    price[i] = x;
    tree->update(x, 1);
  }
  for (int i = 0; i != m; ++i) {
    int x;
    cin >> x;
    money[i] = x;
    tree->update(x, -1);
  }
  int q;
  for (cin >> q; q--;) {
    int t, i, x;
    cin >> t >> i >> x;
    --i;
    if (t == 1) {
      tree->update(price[i], -1);
      price[i] = x;
      tree->update(price[i], 1);
    } else {
      tree->update(money[i], 1);
      money[i] = x;
      tree->update(money[i], -1);
    }
    tree->propagate();
    cout << tree->query() << '\n';
  }
  return 0;
}
