Copying Data

We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly.

More formally, you’ve got two arrays of integers a 1, a 2, …, a n and b 1, b 2, …, b n of length n. Also, you’ve got m queries of two types:

  1. Copy the subsegment of array a of length k, starting from position x, into array b, starting from position y, that is, execute b y + q = a x + q for all integer q (0 ≤ q < k). The given operation is correct — both subsegments do not touch unexistent elements.
  2. Determine the value in position x of array b, that is, find value b x.

For each query of the second type print the result — the value of the corresponding element of array b.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the number of elements in the arrays and the number of queries, correspondingly. The second line contains an array of integers a 1, a 2, …, a n (|a i| ≤ 109). The third line contains an array of integers b 1, b 2, …, b n (|b i| ≤ 109).

Next m lines contain the descriptions of the queries. The i-th line first contains integer t i — the type of the i-th query (1 ≤ t i ≤ 2). If t i = 1, then the i-th query means the copying operation. If t i = 2, then the i-th query means taking the value in array b. If t i = 1, then the query type is followed by three integers x i, y i, k i (1 ≤ x i, y i, k i ≤ n) — the parameters of the copying query. If t i = 2, then the query type is followed by integer x i (1 ≤ x i ≤ n) — the position in array b.

All numbers in the lines are separated with single spaces. It is guaranteed that all the queries are correct, that is, the copying borders fit into the borders of arrays a and b.

Output

For each second type query print the result on a single line.

Examples

input

5 10
1 2 0 -1 3
3 1 5 -2 0
2 5
1 3 3 3
2 5
2 4
2 1
1 2 1 4
2 1
2 4
1 4 2 1
2 2

output

0
3
-1
3
2
3
-1

Solution:

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

const int N = 1111111;

int a[N], b[N], pa[N], pb[N], len[N], v[N];
bool push[N];

void modify(int x, int l, int r, int ll, int rr, int p) {
if (l >= ll && r <= rr) {
    v[x] = p;
    push[x] = true;
    return;
  }
  if (push[x]) {
    v[x+x] = v[x+x+1] = v[x];
    push[x+x] = push[x+x+1] = true;
    push[x] = false;
  }
  int y = (l+r) >> 1;
if (ll <= y) modify(x+x, l, y, ll, rr, p);
  if (rr > y) modify(x+x+1, y+1, r, ll, rr, p);
}

int get(int x, int l, int r, int p) {
if (l == r) return v[x];
if (push[x]) {
v[x+x] = v[x+x+1] = v[x];
push[x+x] = push[x+x+1] = true;
push[x] = false;
}
int y = (l+r) >> 1;
if (p <= y) return get(x+x, l, y, p);
  return get(x+x+1, y+1, r, p);
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1;i<=n;i++) scanf("%d", a+i);
  for (int i=1;i<=n;i++) scanf("%d", b+i);
  push[1] = true;
  v[1] = 0;
  for (int i=1;i<=m;i++) {
    int com;
    scanf("%d", &com);
    if (com == 1) {
      scanf("%d %d %d", pa+i, pb+i, len+i);
      modify(1, 1, n, pb[i], pb[i]+len[i]-1, i);
    } else {
      int pz;
      scanf("%d", &pz);
      int op = get(1, 1, n, pz);
      if (op == 0) printf("%d\n", b[pz]);
      else printf("%d\n", a[pz-pb[op]+pa[op]]);
    }
  }
  return 0;
}