#include <bits/stdc++.h>
using namespace std;
const long long M = (1 << 21) - 1;
pair<long long, long long> st[M];
void update(long long i, long long diff, long long stt, long long end,
            long long cur) {
  if (stt == end) {
    st[cur].first += diff;
    st[cur].second = max(st[cur].first, 0ll);
    return;
  }
  long long mid = (stt + end) / 2;
  if (i <= mid)
    update(i, diff, stt, mid, cur * 2 + 1);
  else
    update(i, diff, mid + 1, end, cur * 2 + 2);
  st[cur].first = st[cur * 2 + 1].first + st[cur * 2 + 2].first;
  st[cur].second = max(st[cur * 2 + 2].second,
                       st[cur * 2 + 2].first + st[cur * 2 + 1].second);
}
long long query(long long v, long long stt, long long end, long long cur) {
  if (stt == end) return stt;
  long long mid = (stt + end) / 2;
  if (st[cur * 2 + 2].second > v) return query(v, mid + 1, end, cur * 2 + 2);
  return query(v - st[cur * 2 + 2].first, stt, mid, cur * 2 + 1);
}
void solve() {
  const long long MAX = 1e6;
  long long n, m;
  cin >> n >> m;
  long long a[n], b[m];
  for (long long i = (0); i < (n); i++) {
    cin >> a[i];
    update(a[i], 1, 1, MAX, 0);
  }
  for (long long i = (0); i < (m); i++) {
    cin >> b[i];
    update(b[i], -1, 1, MAX, 0);
  }
  long long q;
  cin >> q;
  while (q--) {
    long long typ, i, x;
    cin >> typ >> i >> x;
    i--;
    if (typ == 1) {
      update(a[i], -1, 1, MAX, 0);
      a[i] = x;
      update(a[i], 1, 1, MAX, 0);
    } else {
      update(b[i], 1, 1, MAX, 0);
      b[i] = x;
      update(b[i], -1, 1, MAX, 0);
    }
    if (st[0].second == 0)
      cout << -1 << "\n";
    else
      cout << query(0, 1, MAX, 0) << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  for (long long i = (1); i < (t + 1); i++) {
    solve();
    cout << "\n";
  }
}
