#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printVector(const T& t) {
  if (t.size() > 0)
    cout << t[0];
  else {
    cout << "\n";
    return;
  }
  for (int i = int(1); i < int(t.size()); i++) {
    cout << " " << t[i];
  }
  cout << "\n";
}
using ll = long long;
const int mode = 0;
const int MAXA = 1e6 + 1;
const int INF = 1e7;
vector<int> t;
vector<int> lazy;
int segsize;
int init(int n) {
  while (__builtin_popcount(n) > 1 || n < 4) n++;
  t.assign(2 * n, 0);
  lazy.assign(2 * n, 0);
  return n;
}
void push(int v) {
  t[v * 2] += lazy[v];
  lazy[v * 2] += lazy[v];
  t[v * 2 + 1] += lazy[v];
  lazy[v * 2 + 1] += lazy[v];
  lazy[v] = 0;
}
void update(int v, int tl, int tr, int l, int r, int addend) {
  if (l > r) return;
  if (l == tl && tr == r) {
    t[v] += addend;
    lazy[v] += addend;
  } else {
    push(v);
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(r, tm), addend);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, addend);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
  }
}
void UPDATE(int r, int addend) { update(1, 0, segsize - 1, 1, r, addend); }
int query(int v, int tl, int tr, int l, int r) {
  if (l > r) return -INF;
  if (l <= tl && tr <= r) return t[v];
  push(v);
  int tm = (tl + tr) / 2;
  return max(query(v * 2, tl, tm, l, min(r, tm)),
             query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
int QUERY(int l) { return query(1, 0, segsize - 1, l, MAXA); }
int search(int v, int tl, int tr) {
  if (t[v] <= 0) {
    return -1;
  } else if (tl == tr) {
    return tl;
  } else {
    push(v);
    int tm = (tl + tr) / 2;
    if (t[v * 2 + 1] > 0) {
      return search(v * 2 + 1, tm + 1, tr);
    } else {
      return search(v * 2, tl, tm);
    }
  }
}
int SEARCH() { return search(1, 0, segsize - 1); }
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> A(n), B(m);
  for (int i = int(0); i < int(n); i++) cin >> A[i];
  for (int i = int(0); i < int(m); i++) cin >> B[i];
  int q;
  cin >> q;
  segsize = init(MAXA);
  for (int i = int(0); i < int(n); i++) {
    UPDATE(A[i], 1);
  }
  for (int i = int(0); i < int(m); i++) {
    UPDATE(B[i], -1);
  }
  int type, i, val;
  while (q--) {
    cin >> type >> i >> val;
    if (type == 1) {
      int oldval = A[i - 1];
      UPDATE(oldval, -1);
      UPDATE(val, 1);
      A[i - 1] = val;
    } else {
      int oldval = B[i - 1];
      UPDATE(oldval, 1);
      UPDATE(val, -1);
      B[i - 1] = val;
    }
    cout << SEARCH() << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  if (mode == 0) {
    solve();
  } else {
    cin >> t;
    while (t--) {
      solve();
    }
  }
}
