#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
map<pair<int,int>,int> mp;
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,m,T;
cin>>n>>m>>T;
while(T--){
int op;
cin>>op;
if(op==1){
int i,j,k;
cin>>i>>j>>k;
mp[{i,j}]=k;
}
if(op==2){
int i,j;
cin>>i>>j;
cout<<mp[{i,j}]<<endl;
}
}
return 0;
}