#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using C = complex<double>;
const double PI = 3.14159265;
const double eps = 1e-8;
const int N = (1 << 20) + 100;
const int M = 1e9 + 7;
const int inf = 1e9 + 7;
const ll INF = 1e18;
ll pw(ll a, ll b) {
  ll t = 1;
  a %= M;
  for (; b; b >>= 1) {
    if (b & 1) {
      t = t * a % M;
    }
    a = a * a % M;
  }
  return t;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int n, m, q;
int a[N];
int b[N];
int tr[N << 2];
int lz[N << 2];
void update(int u) {
  tr[u] = min(tr[u << 1] + lz[u << 1], tr[u << 1 | 1] + lz[u << 1 | 1]);
}
void modify(int u, int l, int r, int L, int R, int val) {
  if (l >= L && r <= R) {
    lz[u] += val;
    return;
  }
  if (l > R || r < L) return;
  int m = l + r >> 1;
  modify(u << 1, l, m, L, R, val);
  modify(u << 1 | 1, m + 1, r, L, R, val);
  update(u);
}
int query(int u, int l, int r, int val) {
  if (l == r) return l;
  int m = l + r >> 1;
  val -= lz[u];
  if (tr[u << 1 | 1] + lz[u << 1 | 1] < val) {
    return query(u << 1 | 1, m + 1, r, val);
  }
  return query(u << 1, l, m, val);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  int n0 = 1 << 20;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    modify(1, 1, n0, 1, a[i], -1);
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    modify(1, 1, n0, 1, b[i], 1);
  }
  cin >> q;
  while (q--) {
    int op, i, x;
    cin >> op >> i >> x;
    if (op & 1) {
      modify(1, 1, n0, 1, a[i], +1);
      a[i] = x;
      modify(1, 1, n0, 1, a[i], -1);
    } else {
      modify(1, 1, n0, 1, b[i], -1);
      b[i] = x;
      modify(1, 1, n0, 1, b[i], 1);
    }
    if (tr[1] + lz[1] >= 0) {
      puts("-1");
    } else {
      printf("%d\n", query(1, 1, 1 << 20, 0));
    }
  }
}
