#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dbg(T t) {
  cerr << t << endl;
}
template <typename T, typename... Args>
void dbg(T t, Args... args) {
  cerr << t << " ";
  dbg(args...);
}
int ans[200000];
struct xorshift {
  unsigned long long x, y, z, w;
  xorshift()
      : x(1234567891011121314),
        y(91734892562378),
        z(77777777777777),
        w(986732789462378) {}
  unsigned long long next() {
    unsigned long long t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    return w = w ^ (w >> 19) ^ t ^ (t >> 8);
  }
} rng;
struct item {
  long long prior;
  int cnt, rev, val;
  item *l, *r;
  item() {}
  item(unsigned int key, long long prior)
      : val(key), prior(prior), rev(0), l(NULL), r(NULL) {
    cnt = 0;
  }
};
typedef item *pitem;
int cnt(pitem t) { return t ? t->cnt : 0; }
void push(pitem &t) {
  if (t && t->rev) {
    if (t->l) t->l->rev ^= 1;
    if (t->r) t->r->rev ^= 1;
    swap(t->r, t->l);
    t->rev = 0;
  }
}
void upd_cnt(pitem t) {
  if (t) {
    t->cnt = 1 + cnt(t->l) + cnt(t->r);
  }
}
void merge(pitem &t, pitem l, pitem r) {
  push(l);
  push(r);
  if (!l || !r)
    t = l ? l : r;
  else if (l->prior > r->prior)
    merge(l->r, l->r, r), t = l;
  else
    merge(r->l, l, r->l), t = r;
  upd_cnt(t);
}
void split(pitem t, pitem &l, pitem &r, int key, int add = 0) {
  if (!t) return void(l = r = 0);
  push(t);
  int cur_key = add + cnt(t->l);
  if (key <= cur_key)
    split(t->l, l, t->l, key, add), r = t;
  else
    split(t->r, t->r, r, key, add + 1 + cnt(t->l)), l = t;
  upd_cnt(t);
}
void insert(pitem &t, int pos, int val) {
  pitem nt = new item(val, rng.next());
  pitem t1 = 0, t2 = 0;
  split(t, t1, t2, pos - 1);
  merge(t1, t1, nt);
  merge(t, t1, t2);
}
void erase(pitem &t, int key) {
  if (key == cnt(t->l))
    merge(t, t->l, t->r);
  else if (key < cnt(t->l))
    erase(t->l, key);
  else
    erase(t->r, key - 1 - cnt(t->l));
  upd_cnt(t);
}
void reverse(pitem &t, int l, int r) {
  pitem t1 = 0, t2 = 0, t3 = 0;
  split(t, t1, t2, l);
  split(t2, t2, t3, r - l + 1);
  t2->rev ^= 1;
  merge(t, t1, t2);
  merge(t, t, t3);
}
void shift(pitem &t, int l, int r) {
  pitem t1 = 0, t2 = 0, t3 = 0, t4 = 0;
  split(t, t1, t2, l);
  split(t2, t2, t3, r - l);
  split(t3, t3, t4, 1);
  merge(t, t1, t3);
  merge(t2, t2, t4);
  merge(t, t, t2);
}
void fill(pitem t, int add = 0) {
  push(t);
  if (t) {
    ans[cnt(t->l) + add] = t->val;
    fill(t->l, add);
    fill(t->r, add + cnt(t->l) + 1);
  }
}
void pp(pitem t, int add = 0) {
  push(t);
  if (t) {
    pp(t->l, add);
    cout << t->val << ' ';
    pp(t->r, add + cnt(t->l) + 1);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, a, b, d, c, q;
  pitem t = 0;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) {
    cin >> a;
    insert(t, i + 1, a);
  }
  for (int i = 0; i < m; i++) {
    cin >> c >> a >> b;
    if (c == 1) {
      shift(t, a - 1, b - 1);
    } else {
      reverse(t, a - 1, b - 1);
    }
  }
  fill(t, 0);
  for (int i = 0; i < q; i++) {
    cin >> a;
    cout << ans[a - 1] << ' ';
  }
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

You are given an array a of size n, and q queries to it. There are queries of two types: 

  * 1 li ri — perform a cyclic shift of the segment [li, ri] to the right. That is, for every x such that li ≤ x < ri new value of ax + 1 becomes equal to old value of ax, and new value of ali becomes equal to old value of ari; 
  * 2 li ri — reverse the segment [li, ri]. 



There are m important indices in the array b1, b2, ..., bm. For each i such that 1 ≤ i ≤ m you have to output the number that will have index bi in the array after all queries are performed.

Input

The first line contains three integer numbers n, q and m (1 ≤ n, q ≤ 2·105, 1 ≤ m ≤ 100). 

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109). 

Then q lines follow. i-th of them contains three integer numbers ti, li, ri, where ti is the type of i-th query, and [li, ri] is the segment where this query is performed (1 ≤ ti ≤ 2, 1 ≤ li ≤ ri ≤ n). 

The last line contains m integer numbers b1, b2, ..., bm (1 ≤ bi ≤ n) — important indices of the array. 

Output

Print m numbers, i-th of which is equal to the number at index bi after all queries are done.

Example

Input

6 3 5
1 2 3 4 5 6
2 1 3
2 3 6
1 1 6
2 2 1 5 3


Output

3 3 1 5 2 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dbg(T t) {
  cerr << t << endl;
}
template <typename T, typename... Args>
void dbg(T t, Args... args) {
  cerr << t << " ";
  dbg(args...);
}
int ans[200000];
struct xorshift {
  unsigned long long x, y, z, w;
  xorshift()
      : x(1234567891011121314),
        y(91734892562378),
        z(77777777777777),
        w(986732789462378) {}
  unsigned long long next() {
    unsigned long long t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    return w = w ^ (w >> 19) ^ t ^ (t >> 8);
  }
} rng;
struct item {
  long long prior;
  int cnt, rev, val;
  item *l, *r;
  item() {}
  item(unsigned int key, long long prior)
      : val(key), prior(prior), rev(0), l(NULL), r(NULL) {
    cnt = 0;
  }
};
typedef item *pitem;
int cnt(pitem t) { return t ? t->cnt : 0; }
void push(pitem &t) {
  if (t && t->rev) {
    if (t->l) t->l->rev ^= 1;
    if (t->r) t->r->rev ^= 1;
    swap(t->r, t->l);
    t->rev = 0;
  }
}
void upd_cnt(pitem t) {
  if (t) {
    t->cnt = 1 + cnt(t->l) + cnt(t->r);
  }
}
void merge(pitem &t, pitem l, pitem r) {
  push(l);
  push(r);
  if (!l || !r)
    t = l ? l : r;
  else if (l->prior > r->prior)
    merge(l->r, l->r, r), t = l;
  else
    merge(r->l, l, r->l), t = r;
  upd_cnt(t);
}
void split(pitem t, pitem &l, pitem &r, int key, int add = 0) {
  if (!t) return void(l = r = 0);
  push(t);
  int cur_key = add + cnt(t->l);
  if (key <= cur_key)
    split(t->l, l, t->l, key, add), r = t;
  else
    split(t->r, t->r, r, key, add + 1 + cnt(t->l)), l = t;
  upd_cnt(t);
}
void insert(pitem &t, int pos, int val) {
  pitem nt = new item(val, rng.next());
  pitem t1 = 0, t2 = 0;
  split(t, t1, t2, pos - 1);
  merge(t1, t1, nt);
  merge(t, t1, t2);
}
void erase(pitem &t, int key) {
  if (key == cnt(t->l))
    merge(t, t->l, t->r);
  else if (key < cnt(t->l))
    erase(t->l, key);
  else
    erase(t->r, key - 1 - cnt(t->l));
  upd_cnt(t);
}
void reverse(pitem &t, int l, int r) {
  pitem t1 = 0, t2 = 0, t3 = 0;
  split(t, t1, t2, l);
  split(t2, t2, t3, r - l + 1);
  t2->rev ^= 1;
  merge(t, t1, t2);
  merge(t, t, t3);
}
void shift(pitem &t, int l, int r) {
  pitem t1 = 0, t2 = 0, t3 = 0, t4 = 0;
  split(t, t1, t2, l);
  split(t2, t2, t3, r - l);
  split(t3, t3, t4, 1);
  merge(t, t1, t3);
  merge(t2, t2, t4);
  merge(t, t, t2);
}
void fill(pitem t, int add = 0) {
  push(t);
  if (t) {
    ans[cnt(t->l) + add] = t->val;
    fill(t->l, add);
    fill(t->r, add + cnt(t->l) + 1);
  }
}
void pp(pitem t, int add = 0) {
  push(t);
  if (t) {
    pp(t->l, add);
    cout << t->val << ' ';
    pp(t->r, add + cnt(t->l) + 1);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, a, b, d, c, q;
  pitem t = 0;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) {
    cin >> a;
    insert(t, i + 1, a);
  }
  for (int i = 0; i < m; i++) {
    cin >> c >> a >> b;
    if (c == 1) {
      shift(t, a - 1, b - 1);
    } else {
      reverse(t, a - 1, b - 1);
    }
  }
  fill(t, 0);
  for (int i = 0; i < q; i++) {
    cin >> a;
    cout << ans[a - 1] << ' ';
  }
  return 0;
}

```