#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 6;
int n, m, a[MAX], b[MAX];
int tree[(MAX << 2)], lazy[(MAX << 2)], l, r, val;
void Push(int low, int high, int pos) {
  tree[pos] += lazy[pos];
  if (low != high) {
    lazy[(pos << 1)] += lazy[pos];
    lazy[(pos << 1 | 1)] += lazy[pos];
  }
  lazy[pos] = 0;
}
void Upd(int low, int high, int pos) {
  if (l > high || r < low) {
    return;
  }
  if (l <= low && r >= high) {
    tree[pos] += val;
    if (low != high) {
      lazy[(pos << 1)] += val;
      lazy[(pos << 1 | 1)] += val;
    }
    return;
  }
  int mid = ((low + high) >> 1);
  Push(low, mid, (pos << 1));
  Push(mid + 1, high, (pos << 1 | 1));
  Upd(low, mid, (pos << 1));
  Upd(mid + 1, high, (pos << 1 | 1));
  tree[pos] = max(tree[(pos << 1)], tree[(pos << 1 | 1)]);
}
int Qwr(int low, int high, int pos) {
  if (low == high) {
    return (tree[pos] >= 1 ? low : -1);
  }
  int mid = ((low + high) >> 1);
  Push(low, mid, (pos << 1));
  Push(mid + 1, high, (pos << 1 | 1));
  if (tree[(pos << 1 | 1)] >= 1)
    return Qwr(mid + 1, high, (pos << 1 | 1));
  else
    return Qwr(low, mid, (pos << 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    l = 1;
    r = a[i];
    val = 1;
    Upd(1, MAX - 1, 1);
  }
  for (int i = 1; i <= m; ++i) {
    cin >> b[i];
    l = 1;
    r = b[i];
    val = -1;
    Upd(1, MAX - 1, 1);
  }
  int q;
  cin >> q;
  while (q--) {
    int type, i, x;
    cin >> type >> i >> x;
    if (type == 1) {
      l = 1;
      r = a[i];
      val = -1;
      Upd(1, MAX - 1, 1);
      l = 1;
      r = a[i] = x;
      val = 1;
      Upd(1, MAX - 1, 1);
    } else {
      l = 1;
      r = b[i];
      val = 1;
      Upd(1, MAX - 1, 1);
      l = 1;
      r = b[i] = x;
      val = -1;
      Upd(1, MAX - 1, 1);
    }
    cout << Qwr(1, MAX - 1, 1) << "\n";
  }
  return 0;
}
