#include <bits/stdc++.h>
using namespace std;
void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
int ctz(unsigned x) { return __builtin_ctz(x); }
int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
int clz(unsigned x) { return __builtin_clz(x); }
int clzll(unsigned long long x) { return __builtin_clzll(x); }
int popcnt(unsigned x) { return __builtin_popcount(x); }
int popcntll(unsigned long long x) { return __builtin_popcountll(x); }
int bsr(unsigned x) { return 31 ^ clz(x); }
int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
int a[300000], b[300000];
int f[1000000];
int tree[(1 << 21)], lazy[(1 << 21)];
void build(int u, int b, int e) {
  if (b + 1 == e) return tree[u] = f[b], void();
  int m = (b + e) / 2, lc = 2 * u, rc = lc + 1;
  build(lc, b, m);
  build(rc, m, e);
  tree[u] = max(tree[lc], tree[rc]);
}
void push(int u, int d) {
  tree[u] += d;
  lazy[u] += d;
}
void update(int u, int b, int e, int r, int d) {
  if (b >= r) return;
  if (r >= e) return push(u, d);
  int m = (b + e) / 2, lc = 2 * u, rc = lc + 1;
  if (lazy[u]) {
    push(lc, lazy[u]);
    push(rc, lazy[u]);
    lazy[u] = 0;
  }
  update(lc, b, m, r, d);
  update(rc, m, e, r, d);
  tree[u] = max(tree[lc], tree[rc]);
}
int get(int u, int b, int e) {
  if (b + 1 == e) return b;
  int m = (b + e) / 2, lc = 2 * u, rc = lc + 1;
  if (lazy[u]) {
    push(lc, lazy[u]);
    push(rc, lazy[u]);
    lazy[u] = 0;
  }
  return tree[rc] > 0 ? get(rc, m, e) : get(lc, b, m);
}
int main() {
  canhazfast();
  int n, m, q;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++f[a[i] - 1];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
    --f[b[i] - 1];
  }
  for (int i = 1000000 - 2; i >= 0; --i) f[i] += f[i + 1];
  build(1, 0, 1000000);
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int t, j, x;
    cin >> t >> j >> x;
    --j;
    if (t == 1) {
      update(1, 0, 1000000, a[j], -1);
      a[j] = x;
      update(1, 0, 1000000, a[j], 1);
    } else {
      update(1, 0, 1000000, b[j], 1);
      b[j] = x;
      update(1, 0, 1000000, b[j], -1);
    }
    if (tree[1] <= 0)
      cout << "-1\n";
    else
      cout << get(1, 0, 1000000) + 1 << '\n';
  }
  return 0;
}
