#include <bits/stdc++.h>
using namespace std;
const size_t MAXN = 300001;
int data[4001000];
int lazy[4001000];
int a[MAXN], b[MAXN];
void Update(int root, int L, int R, int l, int r, int val) {
  if (lazy[root] != 0) {
    data[root] += lazy[root];
    if (L != R) {
      lazy[root << 1] += lazy[root];
      lazy[root << 1 | 1] += lazy[root];
    }
    lazy[root] = 0;
  }
  if (L > R || r < L || R < l) {
    return;
  }
  if (l <= L && R <= r) {
    data[root] += val;
    if (L != R) {
      lazy[root << 1] += val;
      lazy[root << 1 | 1] += val;
    }
    return;
  }
  int mid = (L + R) / 2;
  Update(root << 1, L, mid, l, r, val);
  Update(root << 1 | 1, mid + 1, R, l, r, val);
  data[root] = max(data[root << 1], data[root << 1 | 1]);
}
int Query(int root, int L, int R) {
  if (lazy[root] != 0) {
    data[root] += lazy[root];
    if (L != R) {
      lazy[root << 1] += lazy[root];
      lazy[root << 1 | 1] += lazy[root];
    }
    lazy[root] = 0;
  }
  if (data[root] <= 0) {
    return -1;
  }
  if (L == R) {
    return L;
  }
  int mid = (L + R) / 2;
  int val = Query(root << 1 | 1, mid + 1, R);
  if (val > 0) {
    return val;
  }
  return Query(root << 1, L, mid);
}
int main() {
  int n, m;
  memset(data, 0, sizeof(data));
  memset(lazy, 0, sizeof(lazy));
  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]);
  }
  for (int i = 1; i <= n; ++i) {
    Update(1, 1, 1000000, 1, a[i], 1);
  }
  for (int i = 1; i <= m; ++i) {
    Update(1, 1, 1000000, 1, b[i], -1);
  }
  int q = 0;
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int t, x, v;
    scanf("%d %d %d", &t, &x, &v);
    if (t == 1) {
      Update(1, 1, 1000000, 1, a[x], -1);
      Update(1, 1, 1000000, 1, v, 1);
      a[x] = v;
    } else {
      Update(1, 1, 1000000, 1, b[x], 1);
      Update(1, 1, 1000000, 1, v, -1);
      b[x] = v;
    }
    printf("%d\n", Query(1, 1, 1000000));
  }
  return 0;
}
