#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int NN = 300005;
const int N = 1000005;
int a[N], seg[4 * N], lazy[4 * N];
void build(int node, int start, int end) {
  if (start == end) {
    seg[node] = a[start];
    return;
  }
  int mid = (start + end) >> 1;
  build(node << 1, start, mid);
  build(node << 1 | 1, mid + 1, end);
  seg[node] = max(seg[node << 1], seg[node << 1 | 1]);
}
void update(int node, int start, int end, int l, int r, int val) {
  if (lazy[node] != 0) {
    seg[node] += lazy[node];
    if (start != end) {
      lazy[node << 1] += lazy[node];
      lazy[node << 1 | 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > end || start > r || end < l) return;
  if (l <= start && end <= r) {
    seg[node] += val;
    if (start != end) {
      lazy[node << 1] += val;
      lazy[node << 1 | 1] += val;
    }
    return;
  }
  int mid = (start + end) >> 1;
  update(node << 1, start, mid, l, r, val);
  update(node << 1 | 1, mid + 1, end, l, r, val);
  seg[node] = max(seg[node << 1], seg[node << 1 | 1]);
}
void lazify(int node, int start, int end) {
  if (lazy[node] != 0) {
    seg[node] += lazy[node];
    if (start != end) {
      lazy[node << 1] += lazy[node];
      lazy[node << 1 | 1] += lazy[node];
    }
    lazy[node] = 0;
  }
}
int query(int node, int l, int r) {
  lazify(node, l, r);
  if (l == r) {
    if (seg[node] > 0)
      return l;
    else
      return -1;
  }
  int mid = (l + r) / 2;
  lazify(node << 1 | 1, mid + 1, r);
  if (seg[node << 1 | 1] > 0)
    return query(node << 1 | 1, mid + 1, r);
  else
    return query(node << 1, l, mid);
}
long long arr1[NN], arr2[NN];
void solve() {
  long long n, m, x, y, z;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> arr1[i];
    a[arr1[i]]++;
  }
  for (long long i = 1; i <= m; i++) {
    cin >> arr2[i];
    a[arr2[i]]--;
  }
  for (long long i = N - 1; i >= 1; i--) a[i] += a[i + 1];
  build(1, 1, N);
  long long q;
  cin >> q;
  for (long long i = 0; i <= q - 1; i++) {
    cin >> x >> y >> z;
    if (x == 1) {
      update(1, 1, N, 1, arr1[y], -1);
      arr1[y] = z;
      update(1, 1, N, 1, arr1[y], 1);
    } else {
      update(1, 1, N, 1, arr2[y], 1);
      arr2[y] = z;
      update(1, 1, N, 1, arr2[y], -1);
    }
    cout << query(1, 1, N) << '\n';
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
