#include <bits/stdc++.h>
using namespace std;
const int N = 52 + 20;
const long long oo = 1e18;
const int MOD = 1e9 + 7;
struct st {
  st *left, *right;
  int mn, l, r, m, lazy;
  st(int l, int r) : l(l), r(r), lazy(0), mn(0) {
    m = (l + r) / 2;
    if (l != r) {
      left = new st(l, m);
      right = new st(m + 1, r);
    } else {
      left = right = nullptr;
    }
  }
  void propagate() {
    if (lazy) {
      mn += lazy;
      if (l != r) left->lazy += lazy;
      if (l != r) right->lazy += lazy;
      lazy = 0;
    }
  }
  void update(int a, int b, int val) {
    propagate();
    if (a == l && b == r) {
      lazy += val;
      propagate();
    } else {
      if (b <= m)
        left->update(a, b, val), right->propagate();
      else if (a > m)
        right->update(a, b, val), left->propagate();
      else
        left->update(a, m, val), right->update(m + 1, b, val);
      mn = min(left->mn, right->mn);
    }
  }
  int get() {
    propagate();
    if (mn >= 0) return -1;
    if (l == r)
      return l;
    else {
      left->propagate();
      right->propagate();
      if (right->mn < 0) return right->get();
      return left->get();
    }
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  while (cin >> n >> m) {
    st tree(1, 1e6);
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      tree.update(1, a[i], -1);
    }
    vector<int> b(m + 1);
    for (int i = 1; i <= m; i++) {
      cin >> b[i];
      tree.update(1, b[i], 1);
    }
    int q;
    cin >> q;
    while (q--) {
      int cmd;
      cin >> cmd;
      if (cmd == 1) {
        int p, x;
        cin >> p >> x;
        tree.update(1, a[p], 1);
        a[p] = x;
        tree.update(1, a[p], -1);
      } else {
        int p, x;
        cin >> p >> x;
        tree.update(1, b[p], -1);
        b[p] = x;
        tree.update(1, b[p], 1);
      }
      cout << tree.get() << '\n';
    }
  }
}
