#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T smax(T& a, const T& b) {
  return a < b ? a = b, b : a;
}
template <typename T>
inline T smin(T& a, const T& b) {
  return a > b ? a = b, b : a;
}
const int INF = 0x3f3f3f3f;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
struct seg {
  int n;
  vector<pair<int, int> > a;
  seg(int _n) {
    n = 1;
    while (n < _n) n <<= 1;
    a.resize(2 * n, {0, 0});
  }
  pair<int, int> merge(const pair<int, int>& i, const pair<int, int>& j) {
    return {i.first + j.first, max(j.second, j.first + i.second)};
  }
  void update(int i, int val) {
    i += n;
    a[i].first += val;
    a[i].second = max(a[i].first, 0);
    while (i > 1) {
      i >>= 1;
      a[i] = merge(a[i << 1], a[(i << 1) | 1]);
    }
  }
  int f(int i, int r_sum) {
    if (i >= n) {
      if (a[i].second + r_sum > 0)
        return i - n;
      else
        return -1;
    }
    if (a[(i << 1) | 1].second + r_sum > 0)
      return f((i << 1) | 1, r_sum);
    else
      return f(i << 1, r_sum + a[(i << 1) | 1].first);
  }
  int query() { return f(1, 0); }
};
int32_t main() {
  seg s((int)1e6 + 100);
  int n, m, q;
  scanf("%d%d", &n, &m);
  vector<int> a(n), b(m);
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - (((0) > (n)) << 1)) {
    scanf("%d", &a[i]);
    s.update(a[i], +1);
  }
  for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));
       i += 1 - (((0) > (m)) << 1)) {
    scanf("%d", &b[i]);
    s.update(b[i], -1);
  }
  scanf("%d", &q);
  while (q--) {
    int t, i, x;
    scanf("%d%d%d", &t, &i, &x);
    i--;
    if (t == 1) {
      s.update(a[i], -1);
      s.update(x, +1);
      a[i] = x;
    } else {
      s.update(b[i], +1);
      s.update(x, -1);
      b[i] = x;
    }
    printf("%d\n", s.query());
  }
  return 0;
}
