/// tree bends in youth
/// 7.11.2023
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N = 1e5 + 5;
const ll NN = 1e6 + 5;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LG = 18;
int a[N],b[N];
int t[4 * N],p[4 * N];
bool th[4 * N];
void push(int v,int l,int r){
if(p[v] != (-1 * N) && th[v] == 0){
if(l != r){
p[v+v] = p[v];
th[v+v] = 0;
th[v+v+1] = 0;
p[v+v+1] = p[v];
p[v] = (-1 * N);
}
}
}
void upd(int v,int l,int r,int ql,int qr,int dif){
push(v,l,r);
if(ql <= l && r <= qr){
th[v] = 0;
p[v] = dif;
push(v,l,r);
return;
}
if(r <ql || qr < l)return;
int mid = (l + r) / 2;
upd(v+v,l,mid,ql,qr,dif);
upd(v+v+1,mid+1,r,ql,qr,dif);
}
int get(int v,int l,int r,int pos,bool toh){
push(v,l,r);
if(l == r){
if(th[v] == 0)return l + p[v];
else return -1;
}
int mid = (l + r) / 2;
if(pos <= mid)return get(v+v,l,mid,pos,toh);
else get(v+v+1,mid+1,r,pos,toh);
}
void solve(){
int n,m;cin >> n >> m;
for(int i = 1;i <= 4 *n;i++){
th[i] = 1;
if(i > n)continue;
cin >> a[i];
}
for(int i = 1;i <= n;i++)cin >> b[i];
while(m--){
int tp;cin >> tp;
if(tp == 1){
int x,y,k;
cin >> y >>x >> k;
upd(1,1,n,x,(x + k - 1),y - x);
}
else{
int x;cin >> x;
int pos = get(1,1,n,x,1);
if(pos == -1)cout << b[x] << '\n';
else cout << a[pos] << '\n';
}
}
}
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("rvq.in","r",stdin);
// freopen("rvq.out","w",stdout);
ll abd= 1;
// cin >> abd;
for(ll i = 1;i <= abd;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
1632C - Strange Test | 673A - Bear and Game |
276A - Lunch Rush | 1205A - Almost Equal |
1020B - Badge | 1353A - Most Unstable Array |
770A - New Password | 1646B - Quality vs Quantity |
80A - Panoramix's Prediction | 1354B - Ternary String |
122B - Lucky Substring | 266B - Queue at the School |
1490A - Dense Array | 1650B - DIV + MOD |
1549B - Gregor and the Pawn Game | 553A - Kyoya and Colored Balls |
1364A - XXXXX | 1499B - Binary Removals |
1569C - Jury Meeting | 108A - Palindromic Times |
46A - Ball Game | 114A - Cifera |
776A - A Serial Killer | 25B - Phone numbers |
1633C - Kill the Monster | 1611A - Make Even |
1030B - Vasya and Cornfield | 1631A - Min Max Swap |
1296B - Food Buying | 133A - HQ9+ |