#include <bits/stdc++.h>
using namespace std;
struct Node {
  int val;
  int upd;
  int lo;
  int hi;
  Node *left;
  Node *right;
};
int n, m;
int a[300005];
int b[300005];
int q;
Node *seg;
Node *init_segtree(int lo, int hi) {
  if (hi < lo) return NULL;
  Node *root = new Node();
  root->val = 0;
  root->upd = 0;
  root->lo = lo;
  root->hi = hi;
  if (lo == hi) {
    root->left = NULL;
    root->right = NULL;
    return root;
  }
  int mid = (lo + hi) / 2;
  root->left = init_segtree(lo, mid);
  root->right = init_segtree(mid + 1, hi);
  return root;
}
int update_segtree(Node *root, int lo, int hi, int upd, int root_update = 0) {
  if (root == NULL) return 0;
  if (root->lo >= lo && root->hi <= hi) {
    root->upd += upd + root_update;
    return root->upd + root->val;
  }
  if (root->lo > hi || root->hi < lo) {
    root->upd += root_update;
    return root->upd + root->val;
  }
  root_update += root->upd;
  root->upd = 0;
  int left = update_segtree(root->left, lo, hi, upd, root_update);
  int right = update_segtree(root->right, lo, hi, upd, root_update);
  root->val = max(left, right);
  return root->val;
}
int query(Node *root) {
  if (root == NULL) return -1;
  root->val += root->upd;
  if (root->lo == root->hi) {
    root->upd = 0;
    if (root->val >= 1) return root->lo;
  }
  int mid = (root->lo + root->hi) / 2;
  int left_val = update_segtree(root->left, root->lo, mid, root->upd);
  int right_val = update_segtree(root->right, mid + 1, root->hi, root->upd);
  root->upd = 0;
  if (root->val <= 0) return -1;
  if (right_val >= 1) return query(root->right);
  return query(root->left);
}
int main() {
  cin >> n >> m;
  seg = init_segtree(0, 1000005);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    update_segtree(seg, 0, a[i], 1);
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    update_segtree(seg, 0, b[i], -1);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t, pos, val;
    cin >> t >> pos >> val;
    pos--;
    int ans = -1;
    if (t == 1) {
      update_segtree(seg, 0, a[pos], -1);
      a[pos] = val;
      update_segtree(seg, 0, a[pos], 1);
      ans = query(seg);
    } else {
      update_segtree(seg, 0, b[pos], 1);
      b[pos] = val;
      update_segtree(seg, 0, b[pos], -1);
      ans = query(seg);
    }
    cout << ans << endl;
  }
}
