#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3ffffff;
const long long LL_INF = 0x3fffffffffffffffll;
const int MOD = 1e9 + 7;
const long long HASH_KEY = 6151;
const long long HASH_MOD = 1610612741;
const int MAXN = 3e6 + 3;
const int MAXL = 1e6 + 3;
struct Node {
  int l, r;
  int max_val, lazy;
  Node *left, *right;
  void add(const int &delta) {
    max_val += delta;
    lazy += delta;
  }
  void maintain() {
    max_val = max(left ? left->max_val : 0, right ? right->max_val : 0);
  }
  void push_down() {
    if (lazy) {
      if (left) {
        left->add(lazy);
      }
      if (right) {
        right->add(lazy);
      }
      lazy = 0;
    }
  }
} node_pool[MAXL * 2], *node_pool_iter(node_pool), *root;
void build(Node *&u, int l, int r) {
  u = node_pool_iter;
  ++node_pool_iter;
  *u = (Node){l, r, 0, 0, NULL, NULL};
  if (l < r) {
    int mid = (l + r) / 2;
    build(u->left, l, mid);
    build(u->right, mid + 1, r);
  }
}
void update(Node *&u, const int &x, const int &y, const int &delta) {
  if (x <= u->l && u->r <= y) {
    u->add(delta);
    return;
  }
  u->push_down();
  int mid = (u->l + u->r) / 2;
  if (x <= mid) {
    update(u->left, x, y, delta);
  }
  if (y > mid) {
    update(u->right, x, y, delta);
  }
  u->maintain();
}
int binary_search(Node *&u) {
  if (u->l == u->r) {
    return u->l;
  }
  u->push_down();
  if (u->right && u->right->max_val > 0) {
    return binary_search(u->right);
  }
  return binary_search(u->left);
}
int a[MAXN], b[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  build(root, 1, MAXL);
  for (int i = int(0); i < int(n); ++i) {
    cin >> a[i];
    update(root, 1, a[i], 1);
  }
  for (int i = int(0); i < int(m); ++i) {
    cin >> b[i];
    update(root, 1, b[i], -1);
  }
  int q, op, pos, val;
  cin >> q;
  while (q--) {
    cin >> op >> pos >> val;
    --pos;
    if (op == 1) {
      update(root, 1, a[pos], -1);
      update(root, 1, val, 1);
      a[pos] = val;
    } else {
      update(root, 1, b[pos], 1);
      update(root, 1, val, -1);
      b[pos] = val;
    }
    cout << (root->max_val > 0 ? binary_search(root) : -1) << "\n";
  }
  return 0;
}
