#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
struct SegmentTree {
  int n;
  vector<int> Tree, LazyTree;
  SegmentTree(int n) {
    this->n = n;
    Tree.assign(4 * n, 0);
    LazyTree.assign(4 * n, 0);
  }
  void update(int c, int s, int e, int l, int r, int v) {
    if (s > r or e < l) {
      return;
    } else if (s >= l and e <= r) {
      Tree[c] += v;
      LazyTree[c] += v;
    } else {
      int m = (s + e) / 2;
      Tree[2 * c] += LazyTree[c];
      LazyTree[2 * c] += LazyTree[c];
      Tree[2 * c + 1] += LazyTree[c];
      LazyTree[2 * c + 1] += LazyTree[c];
      LazyTree[c] = 0;
      update(2 * c, s, m, l, r, v);
      update(2 * c + 1, m + 1, e, l, r, v);
      Tree[c] = min(Tree[2 * c], Tree[2 * c + 1]);
    }
  }
  int query(int c, int s, int e) {
    if (Tree[c] >= 0) {
      return -1;
    } else if (s == e) {
      return s;
    } else {
      Tree[2 * c] += LazyTree[c];
      LazyTree[2 * c] += LazyTree[c];
      Tree[2 * c + 1] += LazyTree[c];
      LazyTree[2 * c + 1] += LazyTree[c];
      LazyTree[c] = 0;
      int m = (s + e) / 2;
      if (Tree[2 * c + 1] < 0) {
        return query(2 * c + 1, m + 1, e);
      } else {
        return query(2 * c, s, m);
      }
    }
  }
} S(N);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    S.update(1, 1, N, 1, a[i], -1);
  }
  vector<int> b(m + 1);
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    S.update(1, 1, N, 1, b[i], 1);
  }
  int q;
  cin >> q;
  while (q--) {
    int t, i, x;
    cin >> t >> i >> x;
    if (t & 1) {
      S.update(1, 1, N, 1, a[i], 1);
      a[i] = x;
      S.update(1, 1, N, 1, a[i], -1);
    } else {
      S.update(1, 1, N, 1, b[i], -1);
      b[i] = x;
      S.update(1, 1, N, 1, b[i], 1);
    }
    cout << S.query(1, 1, N) << '\n';
  }
}
