#include <bits/stdc++.h>
using namespace std;
int n;
int lo[4 * 1000100 + 1], hi[4 * 1000100 + 1], tree[4 * 1000100 + 1],
    delta[4 * 1000100 + 1];
void init(int i, int l, int r) {
  lo[i] = l;
  hi[i] = r;
  if (l == r) return;
  int m = (l + r) / 2;
  init(2 * i, l, m);
  init(2 * i + 1, m + 1, r);
}
void prop(int i) {
  delta[2 * i] += delta[i];
  delta[2 * i + 1] += delta[i];
  delta[i] = 0;
}
void update(int i) {
  tree[i] = max(tree[2 * i] + delta[2 * i], tree[2 * i + 1] + delta[2 * i + 1]);
}
void inc(int i, int l, int r, int val) {
  if (r < lo[i] || hi[i] < l) return;
  if (hi[i] <= r && lo[i] >= l) {
    delta[i] += val;
    return;
  }
  prop(i);
  inc(2 * i, l, r, val);
  inc(2 * i + 1, l, r, val);
  update(i);
}
int query(int i, int l, int r) {
  if (r < lo[i] || hi[i] < l) return -1000100;
  if (hi[i] <= r && lo[i] >= l) return tree[i] + delta[i];
  prop(i);
  int maxLeft = query(2 * i, l, r);
  int maxRight = query(2 * i + 1, l, r);
  update(i);
  return max(maxLeft, maxRight);
}
int m, a[1000100], b[1000100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  init(1, 0, 1000100 - 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    inc(1, 0, a[i], 1);
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    inc(1, 0, b[i], -1);
  }
  int q;
  cin >> q;
  for (int Q = 0; Q < q; Q++) {
    int t, i, x;
    cin >> t >> i >> x;
    i--;
    if (t == 1) {
      inc(1, 0, a[i], -1);
      a[i] = x;
      inc(1, 0, a[i], 1);
    } else {
      inc(1, 0, b[i], 1);
      b[i] = x;
      inc(1, 0, b[i], -1);
    }
    int l = 0, r = 1000100 - 1;
    while (l < r) {
      int mid = (l + r) / 2;
      if (query(1, mid, 1000100 - 1) > 0) {
        l = mid + 1;
      } else {
        r = mid;
      }
    }
    cout << l - 1 << endl;
  }
}
