#include <bits/stdc++.h>
using namespace std;
struct node {
  node* son[2];
  int d, add;
};
node STK[3000001], *head = STK;
node* root;
int a[800001], b[800001];
int stk[2000001];
void update(node* p) { p->d = max(p->son[0]->d, p->son[1]->d); }
void update_add(node* p, int d) {
  p->add += d;
  p->d += d;
}
void pushdown(node* p) {
  if (p->add) {
    if (p->son[0]) update_add(p->son[0], p->add);
    if (p->son[1]) update_add(p->son[1], p->add);
    p->add = 0;
  }
}
void modify(node* p, int L, int R, int l, int r, int d) {
  pushdown(p);
  if (L == l && R == r) {
    update_add(p, d);
    return;
  }
  int mid = (L + R) >> 1;
  if (r <= mid)
    modify(p->son[0], L, mid, l, r, d);
  else if (l > mid)
    modify(p->son[1], mid + 1, R, l, r, d);
  else {
    modify(p->son[0], L, mid, l, mid, d);
    modify(p->son[1], mid + 1, R, mid + 1, r, d);
  }
  update(p);
}
int query(node* p, int L, int R, int l, int r) {
  if (l > r) return 0;
  pushdown(p);
  if (L == l && R == r) {
    return p->d;
  }
  int mid = (L + R) >> 1;
  if (r <= mid)
    return query(p->son[0], L, mid, l, r);
  else if (l > mid)
    return query(p->son[1], mid + 1, R, l, r);
  else
    return max(query(p->son[0], L, mid, l, mid),
               query(p->son[1], mid + 1, R, mid + 1, r));
}
int find(node* p, int L, int R) {
  pushdown(p);
  if (L == R) return L;
  int mid = (L + R) >> 1;
  if (p->son[1]->d > 0)
    return find(p->son[1], mid + 1, R);
  else
    return find(p->son[0], L, mid);
}
node* build_tree(int l, int r) {
  if (l > r) return (node*)(0);
  node* p = ++head;
  if (l == r) {
    p->d = 0;
    p->add = 0;
    p->son[0] = 0;
    p->son[1] = 0;
    return p;
  }
  int mid = (l + r) >> 1;
  p->son[0] = build_tree(l, mid);
  p->son[1] = build_tree(mid + 1, r);
  return p;
}
int n, m, top, q, x, y, z;
pair<int, pair<int, int> > e[2000001];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    stk[++top] = a[i];
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    stk[++top] = b[i];
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d %d %d", &x, &y, &z);
    e[i] = make_pair(x, make_pair(y, z));
    stk[++top] = z;
  }
  sort(stk + 1, stk + 1 + top);
  int k = (int)(unique(stk + 1, stk + 1 + top) - stk) - 1;
  for (int i = 1; i <= n; i++)
    a[i] = (int)(lower_bound(stk + 1, stk + 1 + k, a[i]) - stk);
  for (int i = 1; i <= m; i++)
    b[i] = (int)(lower_bound(stk + 1, stk + 1 + k, b[i]) - stk);
  root = build_tree(1, k);
  for (int i = 1; i <= n; i++) modify(root, 1, k, 1, a[i], 1);
  for (int i = 1; i <= m; i++) modify(root, 1, k, 1, b[i], -1);
  for (int i = 1; i <= q; ++i) {
    x = e[i].first;
    y = e[i].second.first;
    z = (int)(lower_bound(stk + 1, stk + 1 + k, e[i].second.second) - stk);
    if (x == 1) {
      modify(root, 1, k, 1, a[y], -1);
      a[y] = z;
      modify(root, 1, k, 1, a[y], 1);
    } else {
      modify(root, 1, k, 1, b[y], 1);
      b[y] = z;
      modify(root, 1, k, 1, b[y], -1);
    }
    pushdown(root);
    int tmp = root->d;
    if (tmp > 0) {
      tmp = find(root, 1, k);
      printf("%d\n", stk[tmp]);
    } else
      printf("-1\n");
  }
  return 0;
}
