#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <typename T>
bool mmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool mmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
void __print(long long x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
std::mt19937 rng(
    (long long)std::chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1000000007;
const long long INF = 1000000001;
const long long LINF = 1000000000000000001LL;
struct Treap {
  long long n;
  vector<long long> L, R, par, cnt, rv, prio;
  Treap(long long n)
      : n(n), L(n, -1), R(n, -1), par(n, -1), cnt(n, 1), rv(n, 0) {
    srand(time(0));
    for (long long i = (0); i <= (n - 1); ++i) prio.push_back(rand());
  }
  void rev(long long x) { rv[x] ^= 1; }
  long long detach(long long v, vector<long long> &T) {
    long long temp = T[v];
    if (temp != -1) {
      cnt[v] -= cnt[temp];
      par[temp] = -1;
      T[v] = -1;
    }
    return temp;
  }
  void attach(long long v, vector<long long> &T, long long x) {
    cnt[v] += cnt[x];
    par[x] = v;
    T[v] = x;
  }
  long long getRoot(long long v) { return par[v] == -1 ? v : getRoot(par[v]); }
  void push(long long v) {
    if (rv[v]) {
      rv[v] = 0;
      if (L[v] != -1) rev(L[v]);
      if (R[v] != -1) rev(R[v]);
      swap(L[v], R[v]);
    }
  }
  long long deepest(long long v, vector<long long> &T) {
    push(v);
    if (T[v] == -1)
      return v;
    else
      return deepest(T[v], T);
  }
  long long first(long long v) { return deepest(v, L); }
  long long last(long long v) { return deepest(v, R); }
  long long join(long long x, long long y) {
    if (min(x, y) == -1) return max(x, y);
    push(x);
    push(y);
    if (prio[x] > prio[y]) {
      attach(x, R, join(detach(x, R), y));
      return x;
    } else {
      attach(y, L, join(x, detach(y, L)));
      return y;
    }
  }
  pair<long long, long long> split(long long x, long long k) {
    if (x == -1) return {-1, -1};
    push(x);
    long long left = (L[x] == -1 ? 0 : cnt[L[x]]);
    if (k > left) {
      pair<long long, long long> right = split(detach(x, R), k - left - 1);
      return {join(x, right.first), right.second};
    } else {
      pair<long long, long long> left = split(detach(x, L), k);
      return {left.first, join(left.second, x)};
    }
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  long long n, q, m;
  cin >> n >> q >> m;
  Treap treap(n);
  long long root = 0;
  for (long long i = (long long)(1); i <= (long long)(n - 1); ++i)
    root = treap.join(root, i);
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  while (q--) {
    long long t, l, r;
    cin >> t >> l >> r;
    l--;
    r--;
    long long left, right, mid;
    tie(left, mid) = treap.split(root, l);
    tie(mid, right) = treap.split(mid, r - l + 1);
    if (t == 1) {
      long long mid1, mid2;
      tie(mid1, mid2) = treap.split(mid, r - l);
      mid = treap.join(mid2, mid1);
    } else {
      treap.rev(mid);
    }
    root = treap.join(left, treap.join(mid, right));
  }
  while (m--) {
    long long i;
    cin >> i;
    i--;
    long long left, mid, right;
    tie(left, mid) = treap.split(root, i);
    tie(mid, right) = treap.split(mid, 1);
    cout << a[mid] << " ";
    root = treap.join(left, treap.join(mid, right));
  }
  return 0;
}

### Prompt

Create a solution in Cpp for 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;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <typename T>
bool mmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool mmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
void __print(long long x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
std::mt19937 rng(
    (long long)std::chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1000000007;
const long long INF = 1000000001;
const long long LINF = 1000000000000000001LL;
struct Treap {
  long long n;
  vector<long long> L, R, par, cnt, rv, prio;
  Treap(long long n)
      : n(n), L(n, -1), R(n, -1), par(n, -1), cnt(n, 1), rv(n, 0) {
    srand(time(0));
    for (long long i = (0); i <= (n - 1); ++i) prio.push_back(rand());
  }
  void rev(long long x) { rv[x] ^= 1; }
  long long detach(long long v, vector<long long> &T) {
    long long temp = T[v];
    if (temp != -1) {
      cnt[v] -= cnt[temp];
      par[temp] = -1;
      T[v] = -1;
    }
    return temp;
  }
  void attach(long long v, vector<long long> &T, long long x) {
    cnt[v] += cnt[x];
    par[x] = v;
    T[v] = x;
  }
  long long getRoot(long long v) { return par[v] == -1 ? v : getRoot(par[v]); }
  void push(long long v) {
    if (rv[v]) {
      rv[v] = 0;
      if (L[v] != -1) rev(L[v]);
      if (R[v] != -1) rev(R[v]);
      swap(L[v], R[v]);
    }
  }
  long long deepest(long long v, vector<long long> &T) {
    push(v);
    if (T[v] == -1)
      return v;
    else
      return deepest(T[v], T);
  }
  long long first(long long v) { return deepest(v, L); }
  long long last(long long v) { return deepest(v, R); }
  long long join(long long x, long long y) {
    if (min(x, y) == -1) return max(x, y);
    push(x);
    push(y);
    if (prio[x] > prio[y]) {
      attach(x, R, join(detach(x, R), y));
      return x;
    } else {
      attach(y, L, join(x, detach(y, L)));
      return y;
    }
  }
  pair<long long, long long> split(long long x, long long k) {
    if (x == -1) return {-1, -1};
    push(x);
    long long left = (L[x] == -1 ? 0 : cnt[L[x]]);
    if (k > left) {
      pair<long long, long long> right = split(detach(x, R), k - left - 1);
      return {join(x, right.first), right.second};
    } else {
      pair<long long, long long> left = split(detach(x, L), k);
      return {left.first, join(left.second, x)};
    }
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  long long n, q, m;
  cin >> n >> q >> m;
  Treap treap(n);
  long long root = 0;
  for (long long i = (long long)(1); i <= (long long)(n - 1); ++i)
    root = treap.join(root, i);
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  while (q--) {
    long long t, l, r;
    cin >> t >> l >> r;
    l--;
    r--;
    long long left, right, mid;
    tie(left, mid) = treap.split(root, l);
    tie(mid, right) = treap.split(mid, r - l + 1);
    if (t == 1) {
      long long mid1, mid2;
      tie(mid1, mid2) = treap.split(mid, r - l);
      mid = treap.join(mid2, mid1);
    } else {
      treap.rev(mid);
    }
    root = treap.join(left, treap.join(mid, right));
  }
  while (m--) {
    long long i;
    cin >> i;
    i--;
    long long left, mid, right;
    tie(left, mid) = treap.split(root, i);
    tie(mid, right) = treap.split(mid, 1);
    cout << a[mid] << " ";
    root = treap.join(left, treap.join(mid, right));
  }
  return 0;
}

```