#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
struct node {
  int res;
  int id;
} a[maxn], b[maxn];
bool cmp(node a, node b) { return a.res > b.res; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i].res), a[i].id = i;
  for (int i = 0; i < m; i++) scanf("%d", &b[i].res), b[i].id = i;
  int q;
  scanf("%d", &q);
  while (q--) {
    int flag, pos, x;
    scanf("%d %d %d", &flag, &pos, &x);
    if (flag == 1) {
      for (int i = 0; i < n; i++) {
        if (a[i].id == pos - 1) {
          a[i].res = x;
          break;
        }
      }
    } else {
      for (int i = 0; i < m; i++) {
        if (b[i].id == pos - 1) {
          b[i].res = x;
          break;
        }
      }
    }
    sort(a, a + n, cmp);
    sort(b, b + m, cmp);
    int poss = 0;
    int tmp = -1;
    while (true) {
      if (a[poss].res > b[poss].res) {
        tmp = a[poss].res;
        break;
      } else
        poss++;
      if (poss == n || poss == m) break;
    }
    printf("%d\n", tmp);
  }
}
