#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int MAX_LEN = 1000010;
int n, m, q;
int a[MAX_LEN], b[MAX_LEN];
int arr[MAX_LEN << 2], tree[MAX_LEN << 2];
void update_tree(int node, int l, int r, int idx, int val) {
  if (l == r) {
    arr[node] += val;
    tree[node] += val;
    return;
  }
  int mid = (l + r) / 2;
  int left_node = 2 * node;
  int right_node = 2 * node + 1;
  if (idx <= mid)
    update_tree(left_node, l, mid, idx, val);
  else
    update_tree(right_node, mid + 1, r, idx, val);
  arr[node] = arr[left_node] + arr[right_node];
  tree[node] = max(tree[right_node], tree[left_node] + arr[right_node]);
}
int query_tree(int node, int l, int r, int MAXN, int SUM) {
  if (l == r) return l;
  int mid = (l + r) / 2;
  int left_node = 2 * node;
  int right_node = 2 * node + 1;
  int maxn, sum;
  sum = SUM + arr[right_node];
  maxn = tree[right_node] + SUM;
  if (maxn > 0)
    return query_tree(right_node, mid + 1, r, MAXN, SUM);
  else
    return query_tree(left_node, l, mid, maxn, sum);
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(arr, 0, sizeof(arr));
    memset(tree, 0, sizeof(tree));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      update_tree(1, 1, MAX_LEN, a[i], 1);
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d", &b[i]);
      update_tree(1, 1, MAX_LEN, b[i], -1);
    }
    scanf("%d", &q);
    while (q--) {
      int opt, idx, val;
      scanf("%d%d%d", &opt, &idx, &val);
      switch (opt) {
        case 1:
          update_tree(1, 1, MAX_LEN, a[idx], -1);
          a[idx] = val;
          update_tree(1, 1, MAX_LEN, a[idx], 1);
          break;
        case 2:
          update_tree(1, 1, MAX_LEN, b[idx], 1);
          b[idx] = val;
          update_tree(1, 1, MAX_LEN, b[idx], -1);
          break;
      }
      if (tree[1] <= 0)
        printf("-1\n");
      else
        printf("%d\n", query_tree(1, 1, MAX_LEN, 0, 0));
    }
  }
  return 0;
}
