#include<iostream>
#include<vector>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
vector<vector<int>>v(n+1,vector<int>(n+1,0));
for(int l=1;l<=m;l++){
int i,j,k;
cin>>i>>j>>k;
if(i==1){
int u;
cin>>u;
v[j][k]=u;
}
else {
cout<<v[j][k]<<endl;
}
}
}