#include <bits/stdc++.h>
using namespace std;
const int QQ = 3e5 + 10;
const int N = 1e6 + 10;
const int module = 1e9 + 7;
long long rand(long long l, long long r) {
  return 1LL * (1LL * rand() * RAND_MAX + rand()) % (r - l + 1) + l;
}
void doc() {}
void xuli(int TestCase) {
  cout << "Case #" << TestCase << '\n';
  double Pi = atan(1) * 4;
  double Res = 0;
  double R, Start, End;
  cin >> R >> Start >> End;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double l, r, H;
    cin >> l >> r >> H;
    if (H >= R) {
      Res += (r - Start - R);
      Res += 2.0 * (H - R);
      Res += R * Pi;
      Start = 1.0 * r + R;
    } else {
      double Phi = Pi - 2.0 * asin(double(R - H) / R);
      double dist = sqrt(2 * R * H - H * H);
      Res += (r - Start - dist);
      Res += R * Phi;
      Start = r + dist;
    }
  }
  Res += End - Start;
  cout << fixed << setprecision(15) << Res << '\n';
}
int F[N * 4], lazy[N * 4];
void cn(int i, int L, int R) {
  if (lazy[i] == 0) return;
  F[i] += lazy[i];
  if (L != R) {
    lazy[i << 1] += lazy[i];
    lazy[i << 1 | 1] += lazy[i];
  }
  lazy[i] = 0;
}
void update_F(int i, int L, int R, int u, int v, int val) {
  cn(i, L, R);
  if (L > v || R < u) return;
  if (L >= u && R <= v) {
    lazy[i] += val;
    cn(i, L, R);
    return;
  }
  int mid = (L + R) >> 1;
  update_F(i << 1, L, mid, u, v, val);
  update_F(i << 1 | 1, mid + 1, R, u, v, val);
  F[i] = max(F[i << 1], F[i << 1 | 1]);
}
int Get_F(int i, int L, int R, int u, int v) {
  cn(i, L, R);
  if (L > v || R < u) return -1;
  if (L >= u && R <= v) return F[i];
  int mid = (L + R) >> 1;
  int Left = Get_F(i << 1, L, mid, u, v);
  int Right = Get_F(i << 1 | 1, mid + 1, R, u, v);
  return max(Left, Right);
}
void solve() {
  int oo = 1e6;
  int n, m;
  cin >> n >> m;
  int a[n + 1], b[m + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    update_F(1, 1, oo, 1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    update_F(1, 1, oo, 1, b[i], -1);
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int Type, id, x;
    cin >> Type >> id >> x;
    if (Type == 1) {
      update_F(1, 1, oo, 1, a[id], -1);
      update_F(1, 1, oo, 1, x, 1);
      a[id] = x;
    } else {
      update_F(1, 1, oo, 1, b[id], 1);
      update_F(1, 1, oo, 1, x, -1);
      b[id] = x;
    }
    int L = 1;
    int R = 1e6;
    int Res = -1;
    while (L <= R) {
      int mid = (L + R) >> 1;
      int val = Get_F(1, 1, oo, mid, oo);
      if (val > 0) {
        Res = mid;
        L = mid + 1;
      } else
        R = mid - 1;
    }
    cout << Res << '\n';
  }
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  doc();
  solve();
  return 0;
}
