#include <bits/stdc++.h>
using namespace std;
const int N = 300005, M = 1000005, mx_val = 1000000;
int n, m, a[N], b[N];
struct Node {
  int val, l, r;
};
Node t[M << 2];
int lazy[M << 2];
inline int lc(const int &x) { return x << 1; }
inline int rc(const int &x) { return x << 1 | 1; }
void build(int pos, int l, int r) {
  t[pos].l = l;
  t[pos].r = r;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(lc(pos), l, mid);
  build(rc(pos), mid + 1, r);
}
inline void pushdown(int pos) {
  if (!lazy[pos]) return;
  t[lc(pos)].val += lazy[pos];
  t[rc(pos)].val += lazy[pos];
  lazy[lc(pos)] += lazy[pos];
  lazy[rc(pos)] += lazy[pos];
  lazy[pos] = 0;
}
inline void pushup(int pos) {
  t[pos].val = max(t[lc(pos)].val, t[rc(pos)].val);
}
void modify(int l, int r, int val, int pos = 1) {
  if (t[pos].l == l && t[pos].r == r) {
    t[pos].val += val;
    lazy[pos] += val;
    return;
  }
  pushdown(pos);
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (r <= mid)
    modify(l, r, val, lc(pos));
  else if (l > mid)
    modify(l, r, val, rc(pos));
  else
    modify(l, mid, val, lc(pos)), modify(mid + 1, r, val, rc(pos));
  pushup(pos);
}
int query(int l = 1, int r = mx_val, int pos = 1) {
  if (t[pos].val <= 0) return -1;
  if (l == r) return l;
  pushdown(pos);
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (r <= mid)
    return query(l, r, lc(pos));
  else if (l > mid)
    return query(l, r, rc(pos));
  else if (t[rc(pos)].val > 0)
    return query(mid + 1, r, rc(pos));
  else
    return query(l, mid, lc(pos));
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  build(1, 1, mx_val);
  for (int i = 1; i <= n; i++) modify(1, a[i], 1);
  for (int i = 1; i <= m; i++) modify(1, b[i], -1);
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int op, t1, t2;
    scanf("%d%d%d", &op, &t1, &t2);
    if (op == 1) {
      modify(1, a[t1], -1);
      a[t1] = t2;
      modify(1, t2, 1);
    } else {
      modify(1, b[t1], 1);
      b[t1] = t2;
      modify(1, t2, -1);
    }
    printf("%d\n", query());
  }
  return 0;
}
