#include <bits/stdc++.h>
using namespace std;
template <class T>
class implicit_treap {
  struct item {
    int prior, cnt;
    T value;
    bool rev;
    item *l, *r;
    item(T v) {
      value = v;
      rev = false;
      l = NULL;
      r = NULL;
      cnt = 1;
      prior = rand();
    }
  } * root, *node;
  int cnt(item *it) { return it ? it->cnt : 0; }
  void upd_cnt(item *it) {
    if (it) it->cnt = cnt(it->l) + cnt(it->r) + 1;
  }
  void push(item *it) {
    if (it && it->rev) {
      it->rev = false;
      swap(it->l, it->r);
      if (it->l) it->l->rev ^= true;
      if (it->r) it->r->rev ^= true;
    }
  }
  void merge(item *&t, item *l, item *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(item *t, item *&l, item *&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(item *&t, item *element, int key) {
    item *l, *r;
    split(t, l, r, key);
    merge(l, l, element);
    merge(t, l, r);
    l = NULL;
    r = NULL;
  }
  T elementAt(item *&t, int key) {
    push(t);
    T ans;
    if (cnt(t->l) == key)
      ans = t->value;
    else if (cnt(t->l) < key)
      ans = elementAt(t->l, key);
    else
      ans = elementAt(t->r, key - 1 - cnt(t->l));
    return ans;
  }
  void erase(item *&t, int key) {
    push(t);
    if (!t) return;
    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 - cnt(t->l) - 1);
    upd_cnt(t);
  }
  void reverse(item *&t, int l, int r) {
    item *t1, *t2, *t3;
    split(t, t1, t2, l);
    split(t2, t2, t3, r - l + 1);
    t2->rev ^= true;
    merge(t, t1, t2);
    merge(t, t, t3);
  }
  void cyclic_shift(item *&t, int L, int R) {
    if (L == R) return;
    item *l, *r, *m;
    split(t, t, l, L);
    split(l, l, m, R - L + 1);
    split(l, l, r, R - L);
    merge(t, t, r);
    merge(t, t, l);
    merge(t, t, m);
    l = NULL;
    r = NULL;
    m = NULL;
  }
  void output(item *t, vector<T> &arr) {
    if (!t) return;
    push(t);
    output(t->l, arr);
    arr.push_back(t->value);
    output(t->r, arr);
  }

 public:
  implicit_treap() { root = NULL; }
  void insert(T value, int position) {
    node = new item(value);
    insert(root, node, position);
  }
  void erase(int position) { erase(root, position); }
  void reverse(int l, int r) { reverse(root, l, r); }
  T elementAt(int position) { return elementAt(root, position); }
  void cyclic_shift(int L, int R) { cyclic_shift(root, L, R); }
  int size() { return cnt(root); }
  void output(vector<T> &arr) { output(root, arr); }
};
vector<int> arr;
int main() {
  int n, q, m, i, j, l, r, t;
  srand(time(NULL));
  scanf("%d %d %d", &n, &q, &m);
  implicit_treap<int> ttt;
  for (i = 0; i < n; i++) {
    scanf("%d", &j);
    ttt.insert(j, i);
  }
  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &t, &l, &r);
    l--;
    r--;
    if (t == 1) {
      ttt.cyclic_shift(l, r);
    } else {
      ttt.reverse(l, r);
    }
  }
  ttt.output(arr);
  for (i = 0; i < m; i++) {
    scanf("%d", &j);
    j--;
    printf("%d ", arr[j]);
  }
  return 0;
}

### Prompt

In cpp, your task is to solve 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 <class T>
class implicit_treap {
  struct item {
    int prior, cnt;
    T value;
    bool rev;
    item *l, *r;
    item(T v) {
      value = v;
      rev = false;
      l = NULL;
      r = NULL;
      cnt = 1;
      prior = rand();
    }
  } * root, *node;
  int cnt(item *it) { return it ? it->cnt : 0; }
  void upd_cnt(item *it) {
    if (it) it->cnt = cnt(it->l) + cnt(it->r) + 1;
  }
  void push(item *it) {
    if (it && it->rev) {
      it->rev = false;
      swap(it->l, it->r);
      if (it->l) it->l->rev ^= true;
      if (it->r) it->r->rev ^= true;
    }
  }
  void merge(item *&t, item *l, item *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(item *t, item *&l, item *&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(item *&t, item *element, int key) {
    item *l, *r;
    split(t, l, r, key);
    merge(l, l, element);
    merge(t, l, r);
    l = NULL;
    r = NULL;
  }
  T elementAt(item *&t, int key) {
    push(t);
    T ans;
    if (cnt(t->l) == key)
      ans = t->value;
    else if (cnt(t->l) < key)
      ans = elementAt(t->l, key);
    else
      ans = elementAt(t->r, key - 1 - cnt(t->l));
    return ans;
  }
  void erase(item *&t, int key) {
    push(t);
    if (!t) return;
    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 - cnt(t->l) - 1);
    upd_cnt(t);
  }
  void reverse(item *&t, int l, int r) {
    item *t1, *t2, *t3;
    split(t, t1, t2, l);
    split(t2, t2, t3, r - l + 1);
    t2->rev ^= true;
    merge(t, t1, t2);
    merge(t, t, t3);
  }
  void cyclic_shift(item *&t, int L, int R) {
    if (L == R) return;
    item *l, *r, *m;
    split(t, t, l, L);
    split(l, l, m, R - L + 1);
    split(l, l, r, R - L);
    merge(t, t, r);
    merge(t, t, l);
    merge(t, t, m);
    l = NULL;
    r = NULL;
    m = NULL;
  }
  void output(item *t, vector<T> &arr) {
    if (!t) return;
    push(t);
    output(t->l, arr);
    arr.push_back(t->value);
    output(t->r, arr);
  }

 public:
  implicit_treap() { root = NULL; }
  void insert(T value, int position) {
    node = new item(value);
    insert(root, node, position);
  }
  void erase(int position) { erase(root, position); }
  void reverse(int l, int r) { reverse(root, l, r); }
  T elementAt(int position) { return elementAt(root, position); }
  void cyclic_shift(int L, int R) { cyclic_shift(root, L, R); }
  int size() { return cnt(root); }
  void output(vector<T> &arr) { output(root, arr); }
};
vector<int> arr;
int main() {
  int n, q, m, i, j, l, r, t;
  srand(time(NULL));
  scanf("%d %d %d", &n, &q, &m);
  implicit_treap<int> ttt;
  for (i = 0; i < n; i++) {
    scanf("%d", &j);
    ttt.insert(j, i);
  }
  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &t, &l, &r);
    l--;
    r--;
    if (t == 1) {
      ttt.cyclic_shift(l, r);
    } else {
      ttt.reverse(l, r);
    }
  }
  ttt.output(arr);
  for (i = 0; i < m; i++) {
    scanf("%d", &j);
    j--;
    printf("%d ", arr[j]);
  }
  return 0;
}

```