#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 1000002;
ll n[2], q;
ll a[2][mxn], b1[mxn], b2[mxn], f[2];
multiset<ll> s[2];

void ad(ll x, ll y){
	for(int i = x + 1; i < mxn; i += i & -i) b1[i] += x * y, b2[i] += y;
}

ll qr(ll x){
	ll ret = 0;
	for(int i = x + 1; i > 0; i -= i & -i) ret += b1[i] - x * b2[i];
	return ret;
}

void add(int x, int y, int z){
	f[x] += z * a[x][y];
	if(~z) s[x].insert(a[x][y]);
	else s[x].erase(s[x].find(a[x][y]));
	if(x) ad(a[x][y], z);
}

ll qry(ll x, ll y, ll z){
	x -= y, y = min(*s[0].begin(), *s[1].begin());
	return f[0] - min(x, y) * n[0] - f[1] + x * n[1] + qr(x) - !z * max(0ll, x - y);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n[0] >> n[1] >> q;
	
	for(int i = 0; i < 2; i++)
	for(int j = 0; j < n[i]; j++){
		cin >> a[i][j];
		add(i, j, 1);
	}
	
	while(q--){
		int t, x;
		cin >> t >> x;
		if(--t < 2){
			add(t, --x, -1);
			cin >> a[t][x];
			add(t, x, 1);
		}else{
			ll ret = 0xcfcfcfcfcfcfcfcf, y = min(*s[0].begin(), *s[1].begin());
			for(int i = 0; i < 2; i++){
				ret = max(ret, qry(*s[i].begin(), x, i));
				ret = max(ret, qry(*s[i].rbegin(), x, i));
				
				auto it = s[0].lower_bound((i ? *s[i].rbegin() : y) + x);
				if(it != s[0].end()) ret = max(ret, qry(*it, x, 0));
				if(it != s[0].begin()) ret = max(ret, qry(*(--it), x, 0));
			}
			
			cout << ret << endl;
		}
	}
	
	return 0;
}