#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
template <typename T>
inline istream& operator>>(istream& in, pair<T, T>& v) {
  in >> v.first >> v.second;
  return in;
}
template <typename T>
inline ostream& operator<<(ostream& out, pair<T, T> v) {
  out << v.first << " " << v.second;
  return out;
}
template <typename T>
inline istream& operator>>(istream& in, vector<T>& v) {
  for (long long i = 0; i < (long long)((v).size()); i++) in >> v[i];
  return in;
}
template <typename T>
inline ostream& operator<<(ostream& out, vector<T>& v) {
  for (long long i = 0; i < (long long)((v).size()); i++) out << v[i] << " ";
  return out;
}
template <typename T>
inline istream& operator>>(istream& in, pair<vector<T>*, vector<T>*> v) {
  for (long long i = 0; i < (long long)((*v.first).size()); i++)
    in >> (*v.first)[i] >> (*v.second)[i];
  return in;
}
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
struct node {
  long long l, r, t, s;
};
long long n, m;
vector<long long> a, b;
vector<long long> t, x, y, k;
vector<node> z;
void process(long long l, long long r) {
  z.resize(3);
  z[0] = {-1, -1, 0, 0};
  z[1] = {0, n - 1, 0, 0};
  z[2] = {n, n, 0, 0};
  for (long long i = l; i < r; i++) {
    if (t[i] == 1) {
      long long p = -1, q = (long long)((z).size()) - 1;
      for (long long j = 0; j < (long long)((z).size()); j++) {
        if (z[j].r < y[i]) {
          p = j;
        }
        if (z[j].l <= y[i] + k[i] - 1) {
          q = j;
        }
      }
      ++p;
      node l_ = z[p], r_ = z[q];
      l_.r = y[i] - 1;
      r_.s += y[i] + k[i] - r_.l;
      r_.l = y[i] + k[i];
      node n = {y[i], y[i] + k[i] - 1, 1, x[i]};
      z.erase(z.begin() + p, z.begin() + q + 1);
      auto it = z.begin() + p;
      if (l_.l <= l_.r) it = z.insert(it, l_) + 1;
      if (n.l <= n.r) it = z.insert(it, n) + 1;
      if (r_.l <= r_.r) it = z.insert(it, r_) + 1;
    } else {
      for (long long j = 0; j < (long long)((z).size()); j++) {
        if (z[j].l <= x[i] && x[i] <= z[j].r) {
          long long ind = z[j].s + x[i] - z[j].l;
          long long ans = b[ind];
          if (z[j].t == 1) {
            ans = a[ind];
          }
          cout << ans << "\n";
          break;
        }
      }
    }
  }
  long long k = 0;
  for (long long i = 1; i < (long long)((z).size()) - 1; i++) {
    for (long long j = z[i].l; j <= z[i].r; j++) {
      long long ind = z[i].s + j - z[i].l;
      if (z[i].t == 1) {
        b[k] = a[ind];
      } else {
        b[k] = b[ind];
      }
      ++k;
    }
  }
}
inline void solve() {
  long long sq = sqrt(m);
  for (long long i = 0; i < m; i += sq) {
    process(i, min(m, i + sq));
  }
}
inline void read() {
  cin >> n >> m;
  a.resize(n), b.resize(n);
  cin >> a >> b;
  t.resize(m), x.resize(m), y.resize(m), k.resize(m);
  for (long long i = 0; i < m; i++) {
    cin >> t[i];
    if (t[i] == 1) {
      cin >> x[i] >> y[i] >> k[i];
      --x[i], --y[i];
    } else {
      cin >> x[i];
      --x[i];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read();
  solve();
  return 0;
}
