#include<bits/stdc++.h>
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define int long long int
using namespace std;

const int INF = 1e17;
const int mod = 1e9+7;
const int N = 1e6+5;

struct Fenwick{
	
	vector<int> bit;
	int size;
	
	void modify(int j, int v){
		j++;
		for(; j < size; j += j & -j)bit[j] += v;
	}
	
	int query(int j){
		j++;
		int v = 0;
		for(; j > 0; j -= j & -j)v += bit[j];
		return v;
	}
	
	int rangequery(int a, int b){
		return query(b) - query(a - 1);
	}
	
	void rangeupdate(int a, int b, int v){
		modify(a, v);
		modify(b + 1, -v);
	}

	int operator[](int j){
		return query(j);
	}
	int operator()(int x, int y){
		return rangequery(x, y);	
	}
	void operator+=(tuple<int, int> x){
		modify(get<0>(x), get<1>(x));
	}
	void operator+=(tuple<int, int, int> x){
		rangeupdate(get<0>(x), get<1>(x), get<2>(x));
	}
	
	Fenwick(int s){
		s += 3;
		size = s;
		bit = vector<int>(s, 0);
	}
	
};
int n, m, q;
Fenwick cntA(N), cntB(N);
Fenwick sumA(N), sumB(N);

int option(int F, int k, int min_element){
	return (sumA[N-1] - n * min(F - k, min_element)) - (sumB(F-k, N-1) - cntB(F-k, N-1) * (F-k));
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m >> q;	

	vector<int> A(n), B(m);
	multiset<int32_t> mxA, mxB;

	for(int i = 0; i < n; i++){
		cin >> A[i];
		cntA += {A[i], 1};
		sumA += {A[i], A[i]};
		mxA.insert(A[i]);	
	}
	
	for(int i = 0; i < m; i++){
		cin >> B[i];
		cntB += {B[i], 1};
		sumB += {B[i], B[i]};	
		mxB.insert(B[i]);
	}

	while(q--){
		int k, i, x;
		cin >> k;
		if(k == 1){
			cin >> i >> x; i--;
			cntA += {A[i], -1};
			sumA += {A[i], -A[i]};
			mxA.erase(mxA.find(A[i]));

			A[i] = x;	
			
			cntA += {A[i], 1};
			sumA += {A[i], A[i]};	
			mxA.insert(A[i]);
		}	
		
		if(k == 2){
			cin >> i >> x; i--;
			cntB += {B[i], -1};
			sumB += {B[i], -B[i]};
			mxB.erase(mxB.find(B[i]));
			
			B[i] = x;	
			
			cntB += {B[i], 1};
			sumB += {B[i], B[i]};	
			mxB.insert(B[i]);
		}	
		if(k == 3){
			cin >> x;
			int min_element = min(*mxA.begin(), *mxB.begin());
			int opt1 = -INF;
			int opt2 = option(*mxB.rbegin(), x, min_element);
			int opt3 = option(min_element, x, min_element);
	
			auto itr = mxA.lower_bound(*mxB.rbegin() + x);
			if(itr == mxA.end()) itr--;
			for(int i = 0; i < 3; i++){
				opt1 = max(opt1, option(*itr, x, min_element) - (*itr - min(min_element, *itr - x)) + x);
				if(itr == mxA.begin()) break;
				itr--;
			}
			cout << max({opt1, opt2, opt3}) << "\n";
		//	cerr << opt1 << " " << opt2 << " " << opt3 << "\n";
		}
	}
}