```cpp
#include <bits/stdc++.h>
#define MAXN int(2e7+1)
#define INF int(pow(2,31)-1)
using namespace std;
typedef long long LL;
#define f(m,a,b) for(int m=a;m<=b;m++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
int n,q,d,i,j,k;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("title.in","r",stdin);
freopen("title.out","w",stdout);
#endif
cin>>n>>q;
vector< vector<int> > ls(n+1);
while(q--){
cin>>d;
if(d==1){
cin>>i>>j>>k;
if(j>(ls[i].size()-1))
EXC_BAD_ACCESS (code=1, address=0x9c40)
ls[i].resize(j+1);
ls[i][j]=k;
}else if(d==2){
cin>>i>>j;
cout<<ls[i][j]<<endl;
}
}
return 0;
}