#include <bits/stdc++.h>
const int N = 300005, mod = 1000000007;
using namespace std;
struct Node {
  int l, r, mx, lazy;
  Node *left, *right;
  Node(int _l, int _r) {
    l = _l;
    lazy = 0;
    r = _r;
    mx = 0;
    left = NULL;
    right = NULL;
  }
  void extend() {
    if (left != NULL) return;
    int mid = (l + r) / 2;
    left = new Node(l, mid);
    right = new Node(mid + 1, r);
  }
  void update() {
    if (l == r) return;
    mx = ((left->mx < right->mx) ? right->mx : left->mx);
  }
  void takeLazy() {
    mx += lazy;
    if (l != r) {
      extend();
      left->lazy += lazy;
      right->lazy += lazy;
    }
    lazy = 0;
  }
};
Node *groot;
int n, m, i, j, k, l, r, t, ans, a[N], b[N];
int q;
int getint() {
  char c = getchar();
  int t = 0;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    t = (t << 3) + (t << 1);
    t += c - '0';
    c = getchar();
  }
  return t;
}
void upd(Node *node, int L, int R, int x) {
  if (node->lazy) {
    node->takeLazy();
  }
  if (node->l > R || node->r < L) return;
  if (node->l >= L && node->r <= R) {
    node->lazy = x;
    node->takeLazy();
    return;
  }
  node->extend();
  upd(node->left, L, R, x);
  upd(node->right, L, R, x);
  node->update();
}
void fnd(Node *node) {
  if (node->l == node->r) {
    ans = node->l;
    return;
  }
  node->extend();
  node->right->takeLazy();
  node->left->takeLazy();
  if (node->right->mx > 0)
    fnd(node->right);
  else if (node->left->mx > 0)
    fnd(node->left);
  node->update();
}
int main() {
  groot = new Node(1, 1000001);
  cin >> n >> m;
  for (i = 1; i <= n; ++i) {
    a[i] = getint();
    upd(groot, 1, a[i], 1);
  }
  for (i = 1; i <= m; ++i) {
    b[i] = getint();
    upd(groot, 1, b[i], -1);
  }
  cin >> q;
  while (q--) {
    cin >> t;
    if (t == 1) {
      l = getint();
      t = getint();
      upd(groot, 1, a[l], -1);
      a[l] = t;
      upd(groot, 1, a[l], 1);
      ans = -1;
      groot->takeLazy();
      fnd(groot);
      groot->update();
      printf("%d\n", ans);
    } else {
      l = getint();
      t = getint();
      upd(groot, 1, b[l], 1);
      b[l] = t;
      upd(groot, 1, b[l], -1);
      ans = -1;
      groot->takeLazy();
      fnd(groot);
      groot->update();
      printf("%d\n", ans);
    }
  }
  return 0;
}
