#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, M = N, Q = N;
int n, m, a[N], b[M];
int q, opt, l, x;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d%d", &opt, &l, &x);
    if (opt == 1) {
      a[l] = x;
    } else {
      b[l] = x;
    }
  }
  return 0;
}
