#include <bits/stdc++.h>
using namespace std;
const long long MAXSIZE = 1000001;
struct Vertex {
  long long val, l, r, lazy;
  Vertex *lc, *rc;
  Vertex(long long _l, long long _r) {
    val = 0;
    lazy = 0;
    l = _l;
    r = _r;
    if (r - l > 1) {
      long long mid = (r + l) / 2;
      lc = new Vertex(l, mid);
      rc = new Vertex(mid, r);
    } else {
      lc = nullptr;
      rc = nullptr;
    }
  }
  void propagate() {
    if (lazy != 0) {
      rc->lazy += lazy;
      rc->val += lazy;
      lc->lazy += lazy;
      lc->val += lazy;
      lazy = 0;
    }
  }
  void update(long long _l, long long _r, long long _v) {
    if (_l >= r || _r <= l) return;
    if (_l <= l && _r >= r) {
      val += _v;
      lazy += _v;
      return;
    }
    propagate();
    lc->update(_l, _r, _v);
    rc->update(_l, _r, _v);
    val = max(lc->val, rc->val);
  }
  long long query() {
    if (r - l == 1) {
      if (val > 0)
        return l;
      else
        return -1;
    }
    propagate();
    if (val <= 0) return -1;
    if (rc->val > 0) return rc->query();
    return lc->query();
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, q, a, b, c;
  cin >> n >> m;
  vector<long long> meals = {0};
  vector<long long> pupils = {0};
  Vertex *root = new Vertex(0, 1000001);
  for (long long i = 0; i < n; i++) {
    cin >> a;
    root->update(0, a + 1, 1);
    meals.push_back(a);
  }
  for (long long i = 0; i < m; i++) {
    cin >> b;
    root->update(0, b + 1, -1);
    pupils.push_back(b);
  }
  cin >> q;
  while (q--) {
    cin >> a >> b >> c;
    if (a == 1) {
      long long price = meals[b];
      root->update(0, price + 1, -1);
      root->update(0, c + 1, 1);
      meals[b] = c;
      cout << root->query() << "\n";
    } else {
      long long togrogs = pupils[b];
      root->update(0, togrogs + 1, 1);
      root->update(0, c + 1, -1);
      pupils[b] = c;
      cout << root->query() << "\n";
    }
  }
}
