#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;
    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();
}
int findAns() {
  Node *node;
  node = groot;
  node->takeLazy();
  while (1) {
    if (node->l == node->r) return node->l;
    node->extend();
    node->right->takeLazy();
    node->left->takeLazy();
    if (node->right->mx > 0)
      node = node->right;
    else if (node->left->mx > 0)
      node = node->left;
    else
      return -1;
  }
}
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);
      t = findAns();
      printf("%d\n", t);
    } else {
      l = getint();
      t = getint();
      upd(groot, 1, b[l], 1);
      b[l] = t;
      upd(groot, 1, b[l], -1);
      t = findAns();
      printf("%d\n", t);
    }
  }
  return 0;
}
