#include <bits/stdc++.h>
using namespace std;
const int mxn = 3e5 + 5;
const int mxnv = 1e6 + 5;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
int a[mxn];
int b[mxn];
int tree[mxnv << 2];
int lazy[mxnv << 2];
void push(int node) {
  if (lazy[node]) {
    int left = node << 1;
    int right = left | 1;
    tree[left] += lazy[node];
    tree[right] += lazy[node];
    lazy[left] += lazy[node];
    lazy[right] += lazy[node];
    lazy[node] = 0;
  }
  return;
}
void update(int node, int b, int e, int l, int r, int val) {
  if (l > e || r < b) return;
  if (b >= l && e <= r) {
    tree[node] += val;
    lazy[node] += val;
    return;
  }
  int mid = (b + e) >> 1;
  int left = node << 1;
  int right = left | 1;
  push(node);
  update(left, b, mid, l, r, val);
  update(right, mid + 1, e, l, r, val);
  tree[node] = max(tree[left], tree[right]);
}
int query(int node, int b, int e) {
  if (b == e) return b;
  int mid = (b + e) >> 1;
  int left = node << 1;
  int right = left | 1;
  push(node);
  if (tree[right] > 0) return query(right, mid + 1, e);
  return query(left, b, mid);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    update(1, 1, mxnv, 1, a[i], 1);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    update(1, 1, mxnv, 1, b[i], -1);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int tp, pos, val;
    scanf("%d%d%d", &tp, &pos, &val);
    if (tp == 1) {
      update(1, 1, mxnv, 1, a[pos], -1);
      a[pos] = val;
      update(1, 1, mxnv, 1, a[pos], 1);
    } else {
      update(1, 1, mxnv, 1, b[pos], 1);
      b[pos] = val;
      update(1, 1, mxnv, 1, b[pos], -1);
    }
    if (tree[1] <= 0)
      printf("-1\n");
    else
      printf("%d\n", query(1, 1, mxnv));
  }
  return 0;
}
