#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct node {
  node *ch[2] = {0}, *p = 0;
  int cnt = 1, val;
  bool flip = 0;
  node(int val, node* l = 0, node* r = 0) : ch{l, r}, val(val) {}
};
node* update(node* x);
void prop(node* x);
int cnt(node* x) { return x ? x->cnt : 0; }
int dir(node* p, node* x) { return p && p->ch[0] != x; }
void setLink(node* p, node* x, int d) {
  if (p) p->ch[d] = x;
  if (x) x->p = p;
}
void rotate(node* x, int d) {
  if (!x || !x->ch[d]) return;
  node *y = x->ch[d], *z = x->p;
  setLink(x, y->ch[d ^ 1], d);
  setLink(y, x, d ^ 1);
  setLink(z, y, dir(z, x));
  update(x);
  update(y);
}
node* splay(node* x) {
  while (x && x->p) {
    node *y = x->p, *z = y->p;
    int dy = dir(y, x), dz = dir(z, y);
    if (!z)
      rotate(y, dy);
    else if (dy == dz)
      rotate(z, dz), rotate(y, dy);
    else
      rotate(y, dy), rotate(z, dz);
  }
  return x;
}
node* nodeAt(node* x, int pos) {
  if (!x || pos < 0 || pos >= cnt(x)) return 0;
  while (prop(x), cnt(x->ch[0]) != pos)
    if (pos < cnt(x->ch[0]))
      x = x->ch[0];
    else
      pos -= cnt(x->ch[0]) + 1, x = x->ch[1];
  return splay(x);
}
node* merge(node* l, node* r) {
  if (!l || !r) return l ?: r;
  l = nodeAt(l, cnt(l) - 1);
  setLink(l, r, 1);
  return update(l);
}
pair<node*, node*> split(node* t, int pos) {
  if (pos <= 0 || !t) return {0, t};
  if (pos >= cnt(t)) return {t, 0};
  node *l = nodeAt(t, pos - 1), *r = l ? l->ch[1] : 0;
  if (r) l->ch[1] = r->p = 0;
  return {update(l), update(r)};
}
node* insert(node* t, int pos, int val) {
  auto [l, r] = split(t, pos);
  return update(new node(val, l, r));
}
template <class F>
void each(node* x, F f) {
  if (x) prop(x), each(x->ch[0], f), f(x), each(x->ch[1], f);
}
node* update(node* x) {
  if (!x) return 0;
  x->cnt = 1 + cnt(x->ch[0]) + cnt(x->ch[1]);
  setLink(x, x->ch[0], 0), setLink(x, x->ch[1], 1);
  return x;
}
void prop(node* x) {
  if (!x || !x->flip) return;
  if (x->ch[0]) x->ch[0]->flip ^= x->flip;
  if (x->ch[1]) x->ch[1]->flip ^= x->flip;
  swap(x->ch[0], x->ch[1]);
  x->flip = 0;
  update(x);
}
void solve() {
  int n, q, m;
  cin >> n >> q >> m;
  node* root = NULL;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    root = insert(root, i, x);
  }
  for (int i = 0; i < q; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    x--, y--;
    node *l, *c, *r;
    tie(l, r) = split(root, x);
    tie(c, r) = split(r, y - x + 1);
    if (t == 1) {
      auto [cl, cr] = split(c, cnt(c) - 1);
      c = merge(cr, cl);
    } else
      c->flip ^= 1;
    root = merge(l, merge(c, r));
  }
  vector<int> a(n);
  int k = 0;
  each(root, [&](node* x) { a[k++] = x->val; });
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    cout << a[x - 1] << " ";
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  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;
using ll = long long;
struct node {
  node *ch[2] = {0}, *p = 0;
  int cnt = 1, val;
  bool flip = 0;
  node(int val, node* l = 0, node* r = 0) : ch{l, r}, val(val) {}
};
node* update(node* x);
void prop(node* x);
int cnt(node* x) { return x ? x->cnt : 0; }
int dir(node* p, node* x) { return p && p->ch[0] != x; }
void setLink(node* p, node* x, int d) {
  if (p) p->ch[d] = x;
  if (x) x->p = p;
}
void rotate(node* x, int d) {
  if (!x || !x->ch[d]) return;
  node *y = x->ch[d], *z = x->p;
  setLink(x, y->ch[d ^ 1], d);
  setLink(y, x, d ^ 1);
  setLink(z, y, dir(z, x));
  update(x);
  update(y);
}
node* splay(node* x) {
  while (x && x->p) {
    node *y = x->p, *z = y->p;
    int dy = dir(y, x), dz = dir(z, y);
    if (!z)
      rotate(y, dy);
    else if (dy == dz)
      rotate(z, dz), rotate(y, dy);
    else
      rotate(y, dy), rotate(z, dz);
  }
  return x;
}
node* nodeAt(node* x, int pos) {
  if (!x || pos < 0 || pos >= cnt(x)) return 0;
  while (prop(x), cnt(x->ch[0]) != pos)
    if (pos < cnt(x->ch[0]))
      x = x->ch[0];
    else
      pos -= cnt(x->ch[0]) + 1, x = x->ch[1];
  return splay(x);
}
node* merge(node* l, node* r) {
  if (!l || !r) return l ?: r;
  l = nodeAt(l, cnt(l) - 1);
  setLink(l, r, 1);
  return update(l);
}
pair<node*, node*> split(node* t, int pos) {
  if (pos <= 0 || !t) return {0, t};
  if (pos >= cnt(t)) return {t, 0};
  node *l = nodeAt(t, pos - 1), *r = l ? l->ch[1] : 0;
  if (r) l->ch[1] = r->p = 0;
  return {update(l), update(r)};
}
node* insert(node* t, int pos, int val) {
  auto [l, r] = split(t, pos);
  return update(new node(val, l, r));
}
template <class F>
void each(node* x, F f) {
  if (x) prop(x), each(x->ch[0], f), f(x), each(x->ch[1], f);
}
node* update(node* x) {
  if (!x) return 0;
  x->cnt = 1 + cnt(x->ch[0]) + cnt(x->ch[1]);
  setLink(x, x->ch[0], 0), setLink(x, x->ch[1], 1);
  return x;
}
void prop(node* x) {
  if (!x || !x->flip) return;
  if (x->ch[0]) x->ch[0]->flip ^= x->flip;
  if (x->ch[1]) x->ch[1]->flip ^= x->flip;
  swap(x->ch[0], x->ch[1]);
  x->flip = 0;
  update(x);
}
void solve() {
  int n, q, m;
  cin >> n >> q >> m;
  node* root = NULL;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    root = insert(root, i, x);
  }
  for (int i = 0; i < q; i++) {
    int t, x, y;
    cin >> t >> x >> y;
    x--, y--;
    node *l, *c, *r;
    tie(l, r) = split(root, x);
    tie(c, r) = split(r, y - x + 1);
    if (t == 1) {
      auto [cl, cr] = split(c, cnt(c) - 1);
      c = merge(cr, cl);
    } else
      c->flip ^= 1;
    root = merge(l, merge(c, r));
  }
  vector<int> a(n);
  int k = 0;
  each(root, [&](node* x) { a[k++] = x->val; });
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    cout << a[x - 1] << " ";
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}

```