#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <typename T, typename E>
struct SegmentTree {
  using F = function<T(T, T)>;
  using G = function<T(T, E, long long)>;
  using H = function<E(E, E)>;
  long long n;
  vector<T> dat;
  vector<E> laz;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  SegmentTree(F f, G g, H h, T ti, E ei) : f(f), g(g), h(h), ti(ti), ei(ei) {}
  void init(long long n_) {
    n = 1;
    while (n < n_) n <<= 1;
    dat.assign((n << 1) - 1, ti);
    laz.assign((n << 1) - 1, ei);
  }
  void build(const vector<T> &v) {
    long long n_ = v.size();
    init(n_);
    for (long long i = (0); i < ((n_)); i++) dat[i + n - 1] = v[i];
    for (long long i = n - 2; i >= 0; --i) {
      dat[i] = f(dat[(i << 1) + 1], dat[(i << 1) + 2]);
    }
  }
  void eval(long long k, long long l, long long r) {
    if (laz[k] == ei) return;
    dat[k] = g(dat[k], laz[k], r - l);
    if (r - l > 1) {
      laz[(k << 1) + 1] = h(laz[(k << 1) + 1], laz[k]);
      laz[(k << 1) + 2] = h(laz[(k << 1) + 2], laz[k]);
    }
    laz[k] = ei;
  }
  void update(long long a, long long b, E x, long long k = 0, long long l = 0,
              long long r = -1) {
    if (r < 0) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      laz[k] = h(laz[k], x);
      eval(k, l, r);
    } else {
      update(a, b, x, (k << 1) + 1, l, (l + r) / 2);
      update(a, b, x, (k << 1) + 2, (l + r) / 2, r);
      dat[k] = f(dat[(k << 1) + 1], dat[(k << 1) + 2]);
    }
  }
  T query(long long a, long long b, long long k = 0, long long l = 0,
          long long r = -1) {
    if (r < 0) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return ti;
    if (a <= l && r <= b) return dat[k];
    T xl = query(a, b, (k << 1) + 1, l, (l + r) / 2);
    T xr = query(a, b, (k << 1) + 2, (l + r) / 2, r);
    return f(xl, xr);
  }
  long long find(long long k = 0, long long l = 0, long long r = -1) {
    if (r < 0) r = n;
    eval(k, l, r);
    if (dat[k] >= 0) return -1;
    if (r - l == 1) return l;
    T xr = query((l + r) / 2, r, (k << 1) + 2, (l + r) / 2, r);
    if (xr < 0) return find((k << 1) + 2, (l + r) / 2, r);
    return find((k << 1) + 1, l, (l + r) / 2);
  }
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  auto f = [](long long a, long long b) { return min(a, b); };
  auto g = [](long long a, long long b, long long len) { return a + b; };
  auto h = [](long long a, long long b) { return a + b; };
  vector<long long> tmp(1e6 + 10, 0);
  SegmentTree<long long, long long> seg(f, g, h, (1LL << 60), 0);
  seg.build(tmp);
  vector<long long> a(n);
  for (long long i = (0); i < ((n)); i++)
    cin >> a[i], seg.update(0, a[i] + 1, -1);
  vector<long long> b(m);
  for (long long i = (0); i < ((m)); i++)
    cin >> b[i], seg.update(0, b[i] + 1, 1);
  long long q;
  cin >> q;
  for (long long _ = (0); _ < ((q)); _++) {
    long long x, y, z;
    cin >> x >> y >> z, y--;
    if (x == 1) {
      seg.update(0, a[y] + 1, 1);
      seg.update(0, z + 1, -1);
      a[y] = z;
    } else {
      seg.update(0, b[y] + 1, -1);
      seg.update(0, z + 1, 1);
      b[y] = z;
    }
    cout << seg.find() << '\n';
  }
  return 0;
}
