#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 1000;
int l[4 * maxn], r[4 * maxn], lazy[4 * maxn], val[4 * maxn];
int sum[4 * maxn];
void push_down(int x) {
  lazy[x << 1] += lazy[x];
  lazy[x << 1 | 1] += lazy[x];
  val[x << 1] += lazy[x];
  val[x << 1 | 1] += lazy[x];
  lazy[x] = 0;
}
void build(int ll, int rr, int x) {
  l[x] = ll, r[x] = rr;
  lazy[x] = 0, val[x] = 0;
  sum[x] = 0;
  if (ll == rr) {
    return;
  }
  int mid = (ll + rr) / 2;
  build(ll, mid, x << 1);
  build(mid + 1, rr, x << 1 | 1);
}
void update(int ll, int rr, int x, int v) {
  if (ll <= l[x] && rr >= r[x]) {
    lazy[x] += v;
    val[x] += v;
    return;
  }
  push_down(x);
  int mid = (l[x] + r[x]) / 2;
  if (ll <= mid) {
    update(ll, rr, x << 1, v);
  }
  if (rr > mid) update(ll, rr, x << 1 | 1, v);
  val[x] = max(val[x << 1], val[x << 1 | 1]);
}
int query(int x) {
  if (l[x] == r[x]) {
    return l[x];
  }
  push_down(x);
  if (val[x << 1 | 1] > 0) {
    return query(x << 1 | 1);
  } else
    return query(x << 1);
}
int a[maxn], b[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  build(1, 1e6, 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    update(1, a[i], 1, 1);
  }
  for (int i = 1; i <= m; ++i) {
    cin >> b[i];
    update(1, b[i], 1, -1);
  }
  int q, tmp, pos, v;
  cin >> q;
  while (q--) {
    cin >> tmp >> pos >> v;
    if (tmp == 1) {
      update(1, a[pos], 1, -1);
      a[pos] = v;
      update(1, a[pos], 1, 1);
    } else {
      update(1, b[pos], 1, 1);
      cout << sum[1] << " " << val[1] << endl;
      b[pos] = v;
      update(1, b[pos], 1, -1);
    }
    cout << sum[1] << " " << val[1] << endl;
    if (val[1] > 0) {
      cout << query(1) << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
