//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num ;
int a[3000003];
int val[3000003];
set <int> st;
set <int>::iterator it;
bool wasthere = 0;
int main(){
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = a[i];
        while(a[i] > 1){
            for(int j = 2 ; j <= a[i] ; j++){
                if(a[i]%j==0) {st.insert(j); a[i]/=j; wasthere = 1; break;}
            }
            if(!wasthere) { st.insert(num); break; }
        }
        for(it = st.begin() ; it!=st.end() ; it++){
          val[*it]++;
             }
             st.clear();
    }

    for(int i = 1 ; i <= cmax ; i++){
      //cout<<val[i]<<" ";
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num  , cnt;
int a[30000003];
int val[30000003];
int re_primes[30000003];
int primes[30000003];
set <int> st;
set <int>::iterator it;
bool wasthere = 0;
int main(){
    for(int i = 2 ; i <= 500000 ; i++){
        for(int j = i ; j < 500000/i ; j++){
            re_primes[i*j] = 1;
        }
    }
    for(int i = 2 ; i <= 500000 ; i++){
        if(re_primes[i]!=1) {primes[cnt++] = i;}
    }
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = a[i] / 2;
            for(int j = 0 ; primes[j] <= num ; j++){
                if(a[i]%primes[j]==0) {st.insert(primes[j]); a[i]/=primes[j]; wasthere = 1; }
            }
            if(!wasthere) { st.insert(a[i]); }
        for(it = st.begin() ; it!=st.end() ; it++){
          val[*it]++;
             }
             st.clear();
             wasthere = 0;
    }

    for(int i = 1 ; i <= cmax ; i++){
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num  , cnt;
int a[30000003];
int val[30000003];
int re_primes[30000003];
int primes[30000003];
bool wasthere = 0;
int main(){
    for(int i = 2 ; i <= 10000000 ; i++){
        if(primes[i] == 0){
            primes[i] = i;
        for(int j = i*i ; j <= 10000000 ; j+=i)
        if(primes[j] == 0) primes[j] = i;
        }
    }
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = a[i] / 2;
        while(a[i] > 1){
            val[primes[a[i]]]++;
            while(a[i]%primes[a[i]] == 0) {a[i]/=primes[a[i]];}
        }
    }

    for(int i = 1 ; i <= cmax ; i++){
       //cout<<val[i]<<" ";
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num  , cnt;
int a[30000003];
int val[30000003];
int re_primes[30000003];
int primes[30000003];
set <int> st;
set <int>::iterator it;
bool wasthere = 0;
int main(){
    for(int i = 2 ; i <= 50000 ; i++){
        for(int j = i ; j < 50000/i ; j++){
            re_primes[i*j] = 1;
        }
    }
    for(int i = 2 ; i <= 50000 ; i++){
        if(re_primes[i]!=1) {primes[cnt++] = i;}
    }
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = a[i] / 2;
            for(int j = 0 ; primes[j] <= num ; j++){
                if(a[i]%primes[j]==0) {st.insert(primes[j]); a[i]/=primes[j]; wasthere = 1; }
            }
            if(!wasthere) { st.insert(a[i]); }
        for(it = st.begin() ; it!=st.end() ; it++){
          val[*it]++;
             }
             st.clear();
             wasthere = 0;
    }

    for(int i = 1 ; i <= cmax ; i++){
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int a[1000000] , b[1000000] , n , r , l , c , m ,cnt , x ,sum , cmax;
int val[3000003];
int primes[3000003];
int main(){

        for(int i = 2 ; i < sqrt(100000) ; i++){
            for(int j = i ; j <= 100000/i ; j++ ){
                a[i*j] = 1;
            }
        }
    // for(int i = 2 ; i < 10000 ; i++){
    //     if(a[i] != 1){
    //         for(int j = i ; j < 1000000 ; j += i){
    //             val[j]++;
    //         }
    //     }
    // }
    cin>>n;
    for(int i = 0 ; i <  n ; i++){
        cin>>b[i]; cmax = max(b[i],cmax);
    }
    cin>>m;
    for(int k = 0 ; k < m ; k++){
        cin>>l>>r;
         for(int j = 1 ; j < n ; j ++){
                val[b[j]] = 0;
            }
     for(int i = l ; i <= min(cmax,r) ; i++){
        if(a[i] != 1){
            for(int j = i ; j <= cmax ; j += i){
                val[j]++;
            }
        }
    }
    for(int i = 0 ; i < n ; i++) sum+=val[b[i]];
    cout<<sum<<endl;
    sum = 0;
    }

}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num  , cnt;
int a[30000003];
int val[30000003];
int re_primes[30000003];
int primes[30000003];
set <int> st;
set <int>::iterator it;
bool wasthere = 0;
int main(){
    for(int i = 2 ; i <= 5000000 ; i++){
        for(int j = i ; j < 5000000/i ; j++){
            re_primes[i*j] = 1;
        }
    }
    for(int i = 2 ; i <= 5000000 ; i++){
        if(re_primes[i]!=1) {primes[cnt++] = i;}
    }
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = a[i] / 2;
            for(int j = 0 ; primes[j] <= num ; j++){
                if(a[i]%primes[j]==0) {st.insert(primes[j]); a[i]/=primes[j]; wasthere = 1; }
            }
            if(!wasthere) { st.insert(a[i]); }
        for(it = st.begin() ; it!=st.end() ; it++){
          val[*it]++;
             }
             st.clear();
             wasthere = 0;
    }

    for(int i = 1 ; i <= cmax ; i++){
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num  , cnt , b , f;
int val[30000003];
int primes[30000003];
int main(){
    for(int i = 2 ; i <= 10000000 ; i++){
        if(primes[i] == 0){
            primes[i] = i;
        for(int j = (i<<1) ; j <= 10000000 ; j+=i)
        if(primes[j] == 0) primes[j] = i;
        }
    }
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>b; cmax = max(b,cmax);
        while(b > 1){
            val[primes[b]]++;
            f = primes[b];
            while((b % f) == 0){
                b /= f;
            }

        }
    }

    for(int i = 1 ; i <= cmax ; i++){
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l <= cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num ;
int a[3000003];
int val[3000003];
set <int> st;
set <int>::iterator it;
bool wasthere = 0;
int main(){
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = sqrt(a[i]);
        while(a[i] > 1){
            for(int j = 2 ; j <= num ; j++){
                if(a[i]%j==0) {st.insert(j); a[i]/=j; num = a[i]; wasthere = 1; break;}
            }
            if(!wasthere) { st.insert(a[i]); break; }
        }
        for(it = st.begin() ; it!=st.end() ; it++){
          val[*it]++;
             }
             st.clear();
    }

    for(int i = 1 ; i <= cmax ; i++){
      //cout<<val[i]<<" ";
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 9999999
#define N 10000005
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int  n , m , p[N] , a[N] , q[N] , l , r , c;
int main() {
fcin;
   c = pow(10,7);
   for(int i = 2 ; i * i<= 12000000 ; i++){
        if(p[i]==0) p[i] = i;
        for(int j = i ; j*i <= 12000000 ; j++){
            if(p[i*j]==0) p[i*j] = i;
        }
    }
     cin>>n;
     for(int i = 0 ; i < n ; i++) cin>>a[i];
     for(int i = 0 ; i < n ; i++){
         int x = a[i];
         while(x > 1){
             int w = p[x];
            //  cout<<w<<endl;
             if(x%w==0) {q[w]++;}
             while(x%w==0) { x/=w; }
         }
     }
    for(int i = 2 ; i <= c ; i++){
        // cout<<q[i]<<" ";
        q[i] += q[i-1];
    }
     cin>>m;
    for(int i = 0 ; i < m ; i++){
        cin>>l>>r;
        l = min(l,c); r = min(r,c);
        cout<<q[r] - q[l-1]<<endl;
    }

}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num  , cnt , b , f;
int val[10000001];
int primes[10000001];
int main(){
    for(int i = 2 ; i <= 10000000 ; i++){
        if(primes[i] == 0){
            primes[i] = i;
        for(int j = i*2 ; j <= 10000000 ; j+=i)
        if(primes[j] == 0) primes[j] = i;
        }
    }
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>b; cmax = max(b,cmax);
        while(b > 1){
            val[primes[b]]++;
            f = primes[b];
            while((b % f) == 0){
                b /= f;
               //if(primes[a[i]!=f])
              // val[primes[b]]++;
                //if(a[i]==1) break;
            }

        }
    }

    for(int i = 1 ; i <= cmax ; i++){
     //cout<<val[i]<<" ";
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 9999999
#define N 10000005
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int  n , m , p[N] , a[N] , q[N] , l , r , c;
int main() {
fcin;
   c = pow(10,7);
   for(int i = 2 ; i * i<= 10000000 ; i++){
        if(p[i]==0) p[i] = i;
        for(int j = i ; j*i <= 10000000 ; j++){
            if(p[i*j]==0) p[i*j] = i;
        }
    }
     for(int i = 2 ; i <= 10000000 ; i++){
        if(p[i]==0) p[i] = i;
     }
     cin>>n;
     for(int i = 0 ; i < n ; i++) cin>>a[i];
     for(int i = 0 ; i < n ; i++){
         int x = a[i];
         while(x > 1){
            int w = p[x];
             if(x%w==0) {q[w]++;}
             while(x%w==0) { x/=w; }
         }
     }
    for(int i = 2 ; i <= c ; i++){
        q[i] += q[i-1];
    }
     cin>>m;
    for(int i = 0 ; i < m ; i++){
        cin>>l>>r;
        l = min(l,c); r = min(r,c);
        cout<<q[r] - q[l-1]<<endl;
    }

}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int n , m , l , r ,cmax , num  , cnt;
int a[30000003];
int val[30000003];
int re_primes[30000003];
int primes[30000003];
set <int> st;
set <int>::iterator it;
bool wasthere = 0;
int main(){
    // for(int i = 2 ; i <= 5000 ; i++){
    //     for(int j = i ; j < 5000/i ; j++){
    //         re_primes[i*j] = 1;
    //     }
    // }
    // for(int i = 2 ; i <= 5000 ; i++){
    //     if(re_primes[i]!=1) {primes[cnt++] = i;}
    // }
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = a[i] / 2;
        while(a[i] > 1){
            for(int j = 2 ; j <= num ; j++){
                if(a[i]%j==0) {st.insert(j); a[i]/=j; wasthere = 1; num/=2; break; }
            }
            if(!wasthere) {st.insert(a[i]); break;}
            wasthere = 0;
        }
            if(!wasthere) { st.insert(a[i]); }
        for(it = st.begin() ; it!=st.end() ; it++){
          val[*it]++;
             }
             st.clear();
             wasthere = 0;
    }

    for(int i = 1 ; i <= cmax ; i++){
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 9999999
#define N 10000005
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int  n , m , p[N] , a[N] , q[N] , l , r , c;
int main() {
fcin;
   c = pow(10,7);
   for(int i = 2 ; i * i<= 10000000 ; i++){
        if(p[i]==0) p[i] = i;
        for(int j = i ; j*i <= 10000000 ; j++){
            if(p[i*j]==0) p[i*j] = i;
        }
    }
     cin>>n;
     for(int i = 0 ; i < n ; i++) cin>>a[i];
     for(int i = 0 ; i < n ; i++){
         int x = a[i];
         if(p[x]==0) q[x]++;
         else{
         while(x > 1){
            int w = p[x];
            if(w>1){
             if(x%w==0) {q[w]++;}
             while(x%w==0) { x/=w; }
            }
            else break;
         }
         }
     }
    for(int i = 2 ; i <= c ; i++){
        q[i] += q[i-1];
    }
     cin>>m;
    for(int i = 0 ; i < m ; i++){
        cin>>l>>r;
        l = min(l,c); r = min(r,c);
        cout<<q[r] - q[l-1]<<endl;
    }

}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
long long n , m , l , r ,cmax , num ;
long long  a[30000003];
long long val[30000003];
set <long long> st;
set <long long>::iterator it;
bool wasthere = 0;
int main(){
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i]; cmax = max(a[i],cmax);
        num = a[i];
        while(a[i] > 1){
            for(int j = 2 ; j <= a[i] ; j++){
                if(a[i]%j==0) {st.insert(j); a[i]/=j; wasthere = 1; break;}
            }
            if(!wasthere) { st.insert(num); break; }
        }
        for(it = st.begin() ; it!=st.end() ; it++){
          val[*it]++;
             }
             st.clear();
    }

    for(int i = 1 ; i <= cmax ; i++){
      //cout<<val[i]<<" ";
       val[i] += val[i-1];
    }
        cin>>m;
        for(int i = 0; i < m ; i++) {
            cin>>l>>r;
            if(l < cmax){
        if(r > cmax) {cout<<val[cmax] - val[l-1]<<endl;}
        else {cout<<val[r]-val[l-1]<<endl;}
            }
            else cout<<0<<endl;
    }
}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 9999999
#define N 10000005
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int  n , m , p[N] , a[N] , q[N] , l , r , c;
int main() {
fcin;
   c = pow(10,7);
   for(int i = 2 ; i * i<= 10000000 ; i++){
        if(p[i]==0) p[i] = i;
        for(int j = i ; j*i <= 10000000 ; j++){
            if(p[i*j]==0) p[i*j] = i;
        }
    }
     cin>>n;
     for(int i = 0 ; i < n ; i++) cin>>a[i];
     for(int i = 0 ; i < n ; i++){
         int x = a[i];
         while(x > 1){
             int w = p[x];
            if(w>1){
             if(x%w==0) {q[w]++;}
             while(x%w==0) { x/=w; }
            }
         }
     }
    for(int i = 2 ; i <= c ; i++){
        q[i] += q[i-1];
    }
     cin>>m;
    for(int i = 0 ; i < m ; i++){
        cin>>l>>r;
        l = min(l,c); r = min(r,c);
        cout<<q[r] - q[l-1]<<endl;
    }

}


//#include <fsociety>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <iostream>
//end of libraries ;
using namespace std;
int a[1000000] , b[1000000] , n , r , l , c , m ,cnt , x ,sum , cmax;
int val[3000003];
int primes[3000003];
int main(){

        for(int i = 2 ; i < sqrt(10000) ; i++){
            for(int j = i ; j <= 10000/i ; j++ ){
                a[i*j] = 1;
            }
        }
    // for(int i = 2 ; i < 10000 ; i++){
    //     if(a[i] != 1){
    //         for(int j = i ; j < 1000000 ; j += i){
    //             val[j]++;
    //         }
    //     }
    // }
    cin>>n;
    for(int i = 0 ; i <  n ; i++){
        cin>>b[i]; cmax = max(b[i],cmax);
    }
    cin>>m;
    for(int k = 0 ; k < m ; k++){
        cin>>l>>r;
         for(int j = 1 ; j < n ; j ++){
                val[b[j]] = 0;
            }
     for(int i = l ; i <= min(cmax,r) ; i++){
        if(a[i] != 1){
            for(int j = i ; j <= cmax ; j += i){
                val[j]++;
            }
        }
    }
    for(int i = 0 ; i < n ; i++) sum+=val[b[i]];
    cout<<sum<<endl;
    sum = 0;
    }

}


#include <bits/stdc++.h>
using namespace std ;

/*
 * Implicit Treap
 * all the index is 1 based
 */
struct NODE{
    int Value,Prior,Cnt;
    bool Rev;
    NODE *l, *r;
    NODE( int Value = 0,int Prior = 0 ):Value( Value ),Prior( Prior ),Cnt(1),Rev( false ), l( NULL ), r( NULL ){}
};

typedef NODE* P_NODE;
vector<int>ans ;
class TREAP{
    P_NODE Root;
    vector<NODE> Pool;
    int PoolPointer;

    P_NODE Create( int Value,int Prior = rand( ) ){
        P_NODE ret = &Pool[PoolPointer++];
        *ret = NODE( Value,Prior );
        return ret;
    }
    int Count( P_NODE t ){
        return t ? t->Cnt: 0;
    }
    /* Lazy to reverse the child */
    void Push( P_NODE t ){
        if( t && t->Rev ){
            t->Rev = false;
            swap( t->l ,t->r );
            if( t->l ) t->l->Rev ^= true;
            if( t->r ) t->r->Rev ^= true;
        }
    }
    void Update( P_NODE t ){
        if( t ){
            Push( t );
            t->Cnt = 1 + Count(t->l ) + Count(t->r );
        }
    }
    void Split( P_NODE t, int Pos, P_NODE &l, P_NODE &r ,int Add = 0 ){
        if( !t ) return void( l = r = NULL );
        Push( t );
        int Cur_Pos = Add + Count( t->l ) + 1;
        if( Pos <= Cur_Pos ) Split( t->l, Pos, l, t->l,Add ), r = t;
        else Split( t->r, Pos, t->r, r , Add + 1 + Count( t->l ) ), l = t;
        Update( t );
    }
    void Merge( P_NODE &t, P_NODE l, P_NODE r ){
        Push( l ),Push( r );
        if( !l or !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;
        Update( t );
    }
    void Insert( P_NODE &t, P_NODE it ,int Pos ){
        if( !t ) return void( t = it );
        P_NODE l,r;
        Split( t,Pos, l, r );
        Merge( t,l,it );
        Merge( t,t,r );
        Update( t );
    }
    void Erase( P_NODE &t, int Pos ,int Add = 0 ){
        if( !t ) return;
        P_NODE l,r;
        Split( t,Pos,l,t );
        Split( t,2,t,r );
        Merge( t,l,r );
        Update( t );
    }
    void Output( P_NODE t ){
        if( !t ) return;
        Push( t );
        Output( t->l );
        printf("%d\n",t->Value );
        Output( t->r );
    }
    void calc(P_NODE t)
    {
        if( !t ) return;
        Push( t );
        calc( t->l );
        //printf("%d\n",t->Value );
        ans.push_back(t->Value) ;
        calc( t->r );

    }

public:
    TREAP( int PoolSize ) : Root( NULL ), PoolPointer( 0 ){
        srand(time(NULL ) );
        Pool.resize( PoolSize );
    }
    /* Count tot number of node */
    int COUNT( ){
        return Count( Root );
    }
    /* Insert a value in a Pos th position */
    void INSERT( int Pos,int Value ){
        Insert( Root,Create( Value ),Pos );
    }
    /* Erase node from pos */
    void ERASE( int Pos ){
        Erase( Root,Pos );
    }
    /* Reverse a range l -> r */
    void REVERSE( int l, int r){
        P_NODE t1,t2,t3;
        Split( Root,l,t1,t2 );
        Split( t2,(r-l+1)+1,t2,t3 );
        t2->Rev ^= true;
        Merge( Root,t1,t2 );
        Merge( Root,Root,t3 );
    }
    void rightCycleShift(int l, int r)
    {
        P_NODE t1,t2,t3,t4;
        Split( Root,l,t1,t2 );
        Split( t2,(r-l+1),t2,t3 );
        Split( t3,2,t3,t4) ;
//        cout << "t1........" << endl ;
//        Output(t1);
//        cout << ".........." << endl;
//        cout << "t2........" << endl ;
//        Output(t2);
//        cout << ".........." << endl;
//        cout << "t3........" << endl ;
//        Output(t3);
//        cout << ".........." << endl;
//        cout << "t4........" << endl ;
//        Output(t4);
//        cout << ".........." << endl;
        Merge( Root,t1,t3 );
        Merge( Root,Root,t2 );
        Merge( Root,Root,t4 );
    }
    void OUTPUT( void ){
        Output( Root );
    }

    void ansa(void)
    {
        calc(Root) ;
    }
};

TREAP treap(200005) ;

int main()
{
    int n ,q,t, l,r, m , x ;
    cin>>n>>q>>m;
    for(int i = 1 ; i <= n ; i++)
    {
        scanf("%d",&x);
        treap.INSERT(i,x) ;
    }
    for(int i = 0 ; i < q ; i++)
    {
        scanf("%d %d %d",&t,&l,&r);
        if(t==2)treap.REVERSE(l,r) ;
        else if(l!=r)treap.rightCycleShift(l,r);
//        cout << "..................." << endl;
      //  treap.OUTPUT() ;
//        cout << "..................." << endl ;
    }
    //treap.OUTPUT() ;
    treap.ansa() ;

    for(int i = 0 ; i < m ; i++)
    {
        scanf("%d",&x);
        printf("%d ", ans[x-1] ) ;
    }

return 0 ;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int s[2*100000+20];
//int t[2*100000+20];
//int l[2*100000+20];
//int r[2*100000+20];
//int bx[2*100000+20];
void move_right (int l, int r)
{
    int temp = s[r];
    for(int i=r;i>l;i--)
        s[i] = s[i-1];
    s[l] = temp;
    return;
}
void reverse (int l, int r)
{
    while(l<r)
    {
        int temp = s[l];
        s[l] = s[r];
        s[r] = temp;
        l++;
        r--;
    }
    return;
}
int main()
{
    int n,q,m;
    scanf("%d%d%d",&n,&q,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&s[i]);
    for(int i=1;i<=q;i++)
    {
        int t,l,r;
        scanf("%d%d%d",&t,&l,&r);
        if(t == 1)
            move_right(l,r);
        else if(t==2)
            reverse(l,r);
    }

    while(m--)
    {
        int b;
        scanf("%d",&b);
        if(m==0)
            cout << s[b] <<endl;
        else
            cout << s[b] <<" ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int t[2*100000+20];
int l[2*100000+20];
int r[2*100000+20];
int s[120];
int q,n,m;
int f(int a)
{
    for(int i=q;i>=1;i--)
    {
        int ti = t[i],li = l[i],ri = r[i];
        if(a<li||a>ri)
            continue;
        if(ti == 1)
        {
            a=a-1;
            if(a<li)
                a = ri;
        }
        else
        {
            a = (ri+li-a);
        }
    }
    return a;
}

int main()
{
    scanf("%d%d%d",&n,&q,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&s[i]);
    for(int i=1;i<=q;i++)
        scanf("%d%d%d",&t[i],&l[i],&r[i]);
    while(m--)
    {
        int b;
        scanf("%d",&b);
        cout << s[f(b)]<<" ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int t[2*100000+20];
int l[2*100000+20];
int r[2*100000+20];
int s[2*100000+20];
int q,n,m;
int f(int a)
{
    for(int i=q;i>=1;i--)
    {
        int ti = t[i],li = l[i],ri = r[i];
        if(a<li||a>ri)
            continue;
        if(ti == 1)
        {
            a=a-1;
            if(a<li)
                a = ri;
        }
        else
        {
            a = (ri+li-a);
        }
    }
    return a;
}

int main()
{
    scanf("%d%d%d",&n,&q,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&s[i]);
    for(int i=1;i<=q;i++)
        scanf("%d%d%d",&t[i],&l[i],&r[i]);
    while(m--)
    {
        int b;
        scanf("%d",&b);
        if(m==0)
            cout << s[f(b)]<<endl;
        else
            cout << s[f(b)] << " ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

//int bx[2*100000+20];
int s[120];
void f(int t,int l,int r,int x)
{
    if(t==1)
    {
        int v[120];
        x=x%(r-l+1);
        for(int i=l;i<=r;i++)
            v[i]=s[i];
        for(int i=l;i<=r;i++)
            s[i] = v[(i-x)<l?(r-l+i-x+1):(i-x)];
        return;
    }
    else if(t==2)
    {
        while(l<r)
        {
            int temp = s[l];
            s[l] = s[r];
            s[r] = temp;
            l++;
            r--;
        }
    }
    return ;
}
int main()
{
    int n,q,m;
    scanf("%d%d%d",&n,&q,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&s[i]);
    int lastt=0,lastl,lastr;
    int x = 0;
    for(int i=1;i<=q;i++)
    {
        int t,l,r;
        scanf("%d%d%d",&t,&l,&r);
        if(lastt != t || l!=lastl || r!=lastr)
        {
            f(lastt,lastl,lastr,x);
            lastt = t;
            lastl = l;
            lastr = r;
            x = 1;
        }
        else
        {
            if(t==2)
            {
                lastt = 0;
            }
            else
            {
                x++;
            }
        }
    }
    f(lastt,lastl,lastr,x);
    while(m--)
    {
        int b;
        scanf("%d",&b);
        if(m==0)
            cout << s[b] <<endl;
        else
            cout << s[b] <<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
#define MX 200005
using namespace std;
typedef long long ll;

int ara[MX], t[MX], l[MX], r[MX];

int main(){
     int i, j, k;
     int n, q, m;
     scanf("%d %d %d", &n, &q, &m);
     for(i=1; i<=n; ++i) scanf("%d", &ara[i]);
     for(i=1; i<=q; ++i) scanf("%d %d %d", &t[i], &l[i], &r[i]);
     while(m--){
          scanf("%d", &k);
          for(i=q; i>=1; --i){
               if(k<l[i] || k>r[i]) continue;
               if(t[i]==1) k=(k==l[i])?r[i]:k-1;
               else k=r[i]-(k-l[i]);
          }
          printf("%d ", ara[k]);
     }
     return 0;
}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T>inline void printsp(T x) {print(x); putchar(' ');}

template<class T>inline void println(T x) {print(x); putchar('\n');}

template<class T, class U>inline void print(T x, U y){printsp(x);println(x);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 202020

int a[NN], t[NN], l[NN], r[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, u, q, m;

	gn(n, q, m);

	for (int i=1; i<=n; i++) gn(a[i]);

	for (int i=0; i<q; i++) gn(t[i], l[i], r[i]);

	for (int i=0; i<m; i++) {

		gn(u);

		for (int j=q-1; j>=0; j--) {

			if (t[j]==1) {

				if (l[j]<=u && r[j]>=u) {

					if (u==l[j]) u=r[j];

					else u--;

				}

			} else {

				if (l[j]<=u && r[j]>=u) u=l[j]+r[j]-u;

			}

		}

		printsp(a[u]);

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define rands(n) (rand()%n+1)

#define rand0(n) (rands(n)-1)

#define Rands(n) ((INT)rand()*rand()%n+1)

#define Rand0(n) (Rands(n)-1)

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

#define MM 200100

int ty[MM], l[MM], r[MM], a[MM];

int N, M, Q;

int calc(int u)

{

	int ans=u;

	for(int i=0; i<Q; i++){

		int k=ans, s=l[i], t=r[i];

		if(s<=k && k<=t){

			if(ty[i]==1){

				if(k==t) ans=s;

				else ans=k+1;

			}

			else{

				ans=t-k+s;

			}

		}

	}

	return ans;

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

	int _time=clock();

#endif

	int u;

	scanf("%d%d%d", &N, &Q, &M);

	for(int i=1; i<=N; i++) scanf("%d", a+i);

	for(int i=0; i<Q; i++){

		scanf("%d%d%d", &ty[i], &l[i], &r[i]);

	}

	for(int i=1; i<=M; i++){

		scanf("%d", &u);

		printf("%d ", a[calc(u)]);

	}

#ifndef ONLINE_JUDGE

	cerr<<"time:"<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 200200

int a[NN];

pi3 Q[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, q, m;

	scanf("%d %d %d", &n, &q, &m);

	for(int i=1; i<=n; i++) gn(a[i]);

	for(int i=0; i<q; i++){

		gn(Q[i].y);

		gn(Q[i].x.x);

		gn(Q[i].x.y);

	}

	for(int i=0, p; i<m; i++){

		gn(p);

		for(int j=q; j--; ){

			if(p<Q[j].x.x || Q[j].x.y<p) continue;

			if(Q[j].y==1){

				p--;

				if(p<Q[j].x.x) p=Q[j].x.y;

			}

			else p=Q[j].x.y-(p-Q[j].x.x);

		}

		if(i<m-1) printsp(a[p]);

		else println(a[p]);

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define cb(x) ((x)*(x)*(x))

#define pi 3.1415926535897932384626433832795

#define x first

#define y second

#define eps 1e-7

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;}print(x/10);putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x);putchar('\n');}

template <class T> inline void printsp(T x) {print(x);putchar(' ');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

#define DEBUG

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 200010

int n, q, m, c;

int a[NN], t[NN], x[NN], y[NN];

void Kong(int u) {

	for(int i=q; i>0; i--) {

		if(u<x[i] or u>y[i]) continue;

		if(t[i]==1) {

			if(u==x[i]) u=y[i];

			else u--;

		}

		else u=x[i]+y[i]-u;

	}

	printsp(u);

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	gn(n, q, m);

	for(int i=1; i<=n; i++) gn(a[i]);

	for(int i=1; i<=q; i++) gn(t[i], x[i], y[i]);

	while(m--) {

		gn(c);

		Kong(c);

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 200010;

int a[maxn];

int t[maxn], l[maxn], r[maxn];

int main() {

	int n, q, m, id;

	cin >> n >> q >> m;

	for( int i = 1; i <= n; i ++ ) cin >> a[i];

	for( int i = 1; i <= q; i ++ ) cin >> t[i] >> l[i] >> r[i];

	for( int i = 1; i <= m; i ++ ) {

		cin >> id;

		for( int j = q; j > 0; j -- ) {

			if( t[j] == 1 ) {

				if( l[j] < id and  id <= r[j] ) id --;

				else if( id == l[j] ) id = r[j];

			} else {

				if( l[j] <= id and id <= r[j] ) id = l[j] + r[j] - id;

			}

		}

		cout << a[id] << endl;

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define rands(n) (rand()%n+1)

#define rand0(n) (rands(n)-1)

#define Rands(n) ((INT)rand()*rand()%n+1)

#define Rand0(n) (Rands(n)-1)

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

#define MM 200100

int ty[MM], l[MM], r[MM], a[MM];

int N, M, Q;

int calc(int u)

{

	int ans=u;

	for(int i=Q-1; i>=0; i--){

		int k=ans, s=l[i], t=r[i];

		if(s<=k && k<=t){

			if(ty[i]==1){

				if(k==s) ans=t;

				else ans=k-1;

			}

			else{

				ans=t-k+s;

			}

		}

	}

	return ans;

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.txt", "r", stdin);

	int _time=clock();

#endif

	int u;

	scanf("%d%d%d", &N, &Q, &M);

	for(int i=1; i<=N; i++) scanf("%d", a+i);

	for(int i=0; i<Q; i++){

		scanf("%d%d%d", &ty[i], &l[i], &r[i]);

	}

	for(int i=1; i<=M; i++){

		scanf("%d", &u);

		printf("%d ", a[calc(u)]);

	}

#ifndef ONLINE_JUDGE

	cerr<<"time:"<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

int n, q, m;

#define NN 100011

int a[NN], l[NN], r[NN], t[NN];

int solve(int u, int n) {

	if(n<0) {

		return a[u];

	}

	if(u>r[n] || u<l[n]) return solve(u, n-1);

	if(t[n]==1) {

		if(u==l[n]) return solve(r[n], n-1);

		return solve(u-1, n-1);

	}

	return solve(l[n]+r[n]-u, n-1);

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	cin >> n >> q >> m;

	for(int i=0; i<n; i++) scanf("%d", a+i);

	for(int i=0; i<q; i++) {

		scanf("%d %d %d", t+i, l+i, r+i); l[i]--; r[i]--;

	}

	for(int i=0; i<m; i++) {

		int b;

		scanf("%d", &b); b--;

		int ans=solve(b, q-1);

		printf("%d ", ans);

	}

#ifndef ONLINE_JUDGE

	cerr<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define cb(x) ((x)*(x)*(x))

#define pi 3.1415926535897932384626433832795

#define x first

#define y second

#define eps 1e-7

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template <class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;}print(x/10);putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x);putchar('\n');}

template <class T> inline void printsp(T x) {print(x);putchar(' ');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

#define DEBUG

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 200010

int n, q, m, c;

int a[NN], t[NN], x[NN], y[NN];

void Kong(int u) {

	for(int i=q; i>0; i--) {

		if(u<x[i] or u>y[i]) continue;

		if(t[i]==1) {

			if(u==x[i]) u=y[i];

			else u--;

		}

		else u=x[i]+y[i]-u;

	}

	printsp(a[u]);

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	gn(n, q, m);

	for(int i=1; i<=n; i++) gn(a[i]);

	for(int i=1; i<=q; i++) gn(t[i], x[i], y[i]);

	while(m--) {

		gn(c);

		Kong(c);

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(int &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

inline void gn(INT &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

inline void gn(DO &x)  {scanf("%lf", &x);}

inline void newline() {putchar('\n');}

inline void sp() {putchar(' ');}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 200010

int tp[NN], l[NN], r[NN];

int a[NN];

int main(){

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

#endif

	int n, m, q;

	cin>>n>>q>>m;

	for (int i=1; i<=n; i++) gn(a[i]);

	for (int i=0; i<q; i++) {

		gn(tp[i]);

		gn(l[i]);

		gn(r[i]);

	}

	reverse(tp, tp+q);

	reverse(l, l+q);

	reverse(r, r+q);

	for (int i=0, u; i<m; i++) {

		gn(u);

		int p=u;

		for (int j=0; j<q; j++) {

			if (l[j]<=p && r[j]>=p) {

				if (tp[j]==1) {

					if (p==l[j]) p=r[j];

					else p--;

				}

				else {

					int v=p-l[j];

					int L=r[j]-l[j]+1;

					v=L-v-1;

					p=l[j]+v;

				}

			}

		}

		print(a[p]);sp();

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define mp make_pair

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

inline void gn(int &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

inline void gn(INT &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

inline void gn(DO &x)  {scanf("%lf", &x);}

inline void newline() {putchar('\n');}

inline void sp() {putchar(' ');}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100010

int tp[NN], l[NN], r[NN];

int a[NN];

int main(){

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

//	freopen("out.out", "w", stdout);

#endif

	int n, m, q;

	cin>>n>>q>>m;

	for (int i=1; i<=n; i++) gn(a[i]);

	for (int i=0; i<q; i++) {

		gn(tp[i]);

		gn(l[i]);

		gn(r[i]);

	}

	reverse(tp, tp+q);

	reverse(l, l+q);

	reverse(r, r+q);

	for (int i=0, u; i<m; i++) {

		gn(u);

		int p=u;

		for (int j=0; j<q; j++) {

			if (l[j]<=p && r[j]>=p) {

				if (tp[j]==1) {

					if (p==l[j]) p=r[j];

					else p--;

				}

				else {

					int v=p-l[j];

					int L=r[j]-l[j]+1;

					v=L-v-1;

					p=l[j]+v;

				}

			}

		}

		print(a[p]);sp();

	}

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define mod 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define sz(a) ((int)a.size())

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

#define rep(i, a, b) for(int i=a; i<b; i++)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<INT, INT> PII;

typedef pair<pii, int> ppi;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)

    #define lld "%I64d"

#else

    #define lld "%lld"

#endif

int n, q, m;

#define NN 200011

int a[NN], l[NN], r[NN], t[NN];

int solve(int u, int n) {

	if(n<0) {

		return a[u];

	}

	if(u>r[n] || u<l[n]) return solve(u, n-1);

	if(t[n]==1) {

		if(u==l[n]) return solve(r[n], n-1);

		return solve(u-1, n-1);

	}

	return solve(l[n]+r[n]-u, n-1);

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

	int _time=clock();

#endif

	cin >> n >> q >> m;

	for(int i=0; i<n; i++) scanf("%d", a+i);

	for(int i=0; i<q; i++) {

		scanf("%d %d %d", t+i, l+i, r+i); l[i]--; r[i]--;

	}

	for(int i=0; i<m; i++) {

		int b;

		scanf("%d", &b); b--;

		int ans=solve(b, q-1);

		printf("%d ", ans);

	}

#ifndef ONLINE_JUDGE

	cerr<<(int)(clock()-_time)<<endl;

#endif

	return 0;

}


/*
 * test.cpp
 *
 *
 *      Author: Fireworks
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>

using namespace std;

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
long long mod = 1000000007LL;
long long base = 10000007;
long long large = 1000000000000000000LL;

int main(){

	int n,q,m;
	cin>>n>>q>>m;
	vector<int> a(n,0);
	for(int i=0;i<n;i++) cin>>a[i];
	vector<iii> qu;
	for(int i=0;i<q;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		y--;z--;
		qu.push_back(iii(ii(y,z),x));
	}
	reverse(qu.begin(),qu.end());
	while(m--){
		int x;
		cin>>x;
		x--;
		for(int i=0;i<q;i++){
			int l = qu[i].first.first;
			int r = qu[i].first.second;
			if(x>=l&&x<=r){
				if(qu[i].second==2) x = r-(x-l);
				else{
					if(x>l) x--;
					else x = r;
				}
			}
		}
		cout<<a[x]<<" ";
	}

	/*
	int totalcase;
	int testcase=0;
	cin>>totalcase;
	ofstream out;
	out.open("result.txt");

	while(totalcase--){
		testcase++;
		out<<"Case #"<<testcase<<": ";
		cout<<testcase<<": "<<endl;

		//GOGOGO

		//END
	}
	out.close();
	*/

	return 0;
}


#include <iostream>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<set>
#define LL long long
#define INF 1000000009
#define maxn 10000009
#include <set>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
struct yh
{
	int t,l,r;
}c[300000];
int a[200001],b[200];
int main()
{
	int n,q,m;
	scanf("%d %d %d",&n,&q,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<q;i++)
	{
		scanf("%d %d %d",&c[i].t,&c[i].l,&c[i].r);
	}
	for(int i=0;i<m;i++)
	{
		scanf("%d",&b[i]);
	}
	for(int i=0;i<q;i++)
	{
	//	printf("!%d %d\n",c[i].l,c[i].r);
		for(int j=0;j<m;j++)
		{
			if(c[i].l<=b[j]&&b[j]<=c[i].r)
			{
				//printf("b[%d=%d\n",j,b[j]);
				if(c[i].t==1)
				{
					if(b[j]==c[i].r)
					{
						b[j]=c[i].l;
					}
					else
					{
						b[j]=b[j]+1;
					}
				}
				else
				{
					b[j]=(c[i].r+c[i].l)-b[j];
				}
			}
	}
	//printf("\n");
	}
	for(int i=0;i<m;i++)
	{
		if(i!=m-1)
		printf("%d ",a[b[i]]);
		else
		printf("%d\n",a[b[i]]);
	}
}


#include <iostream>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<set>
#define LL long long
#define INF 1000000009
#define maxn 10000009
#include <set>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
struct yh
{
	int t,l,r;
}c[300000];
int a[200001],b[200];
int main()
{
	int n,q,m;
	scanf("%d %d %d",&n,&q,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<q;i++)
	{
		scanf("%d %d %d",&c[i].t,&c[i].l,&c[i].r);
	}
	for(int i=0;i<m;i++)
	{
		scanf("%d",&b[i]);
	}
	for(int i=q;i>=0;i--)
	{
	//	printf("!%d %d\n",c[i].l,c[i].r);
		for(int j=0;j<m;j++)
		{
			if(c[i].l<=b[j]&&b[j]<=c[i].r)
			{
				//printf("b[%d=%d\n",j,b[j]);
				if(c[i].t==1)
				{
					if(b[j]==c[i].l)
					{
						b[j]=c[i].r;
					}
					else
					{
						b[j]=b[j]-1;
					}
				}
				else
				{
					b[j]=(c[i].r+c[i].l)-b[j];
				}
			}
	    }
	//printf("\n");
	}
	for(int i=0;i<m;i++)
	{
		if(i!=m-1)
		printf("%d ",a[b[i]]);
		else
		printf("%d\n",a[b[i]]);
	}
}


#include<bits/stdc++.h>
using namespace std;

#define mx 100010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)cin>>ara[i];
    for(int i=1;i<=qu;i++)cin>>tt[i]>>lft[i]>>rgt[i];
    for(int i=1;i<=m;i++)cin>>b[i];

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            int t=tt[i],l=lft[i],r=rgt[i];
            if(b[j]>=l and b[j]<=r){
                if(t==1){
                    if(b[j]==l)b[j]=r;
                    else b[j]--;
                }
                else b[j]=r-(b[j]-l);
            }
        }
    }
    for(int i=1;i<=m;i++)
        cout<<ara[b[i]]<<' ';
}


#include<bits/stdc++.h>
using namespace std;

#define mx 100010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)cin>>ara[i];
    for(int i=1;i<=qu;i++)cin>>tt[i]>>lft[i]>>rgt[i];
    for(int i=1;i<=m;i++)cin>>b[i];

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            if(b[j]>=lft[i] and b[j]<=rgt[i]){
                if(tt[i]==1){
                    if(b[j]==lft[i])b[j]=rgt[i];
                    else b[j]--;
                }
                else b[j]=rgt[i]-(b[j]-lft[i]);
            }
        }
    }
    for(int i=1;i<=m;i++)
        cout<<ara[b[i]]<<' ';
}


#include<bits/stdc++.h>
using namespace std;

#define mx 200010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)scanf("%d",&ara[i]);
    for(int i=1;i<=qu;i++)scanf("%d %d %d",&tt[i],&lft[i],rgt[i]);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]);

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            int t=tt[i],l=lft[i],r=rgt[i];
            if(b[j]>=l and b[j]<=r){
                if(t==1){
                    if(b[j]==l)b[j]=r;
                    else b[j]--;
                }
                else b[j]=r+l-b[j];
            }
        }
    }
    for(int i=1;i<=m;i++)
        printf("%d",&ara[b[i]]);
}


#include<bits/stdc++.h>
using namespace std;

#define mx 200010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)cin>>ara[i];
    for(int i=1;i<=qu;i++)cin>>tt[i]>>lft[i]>>rgt[i];
    for(int i=1;i<=m;i++)cin>>b[i];

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            int t=tt[i],l=lft[i],r=rgt[i];
            if(b[j]>=l and b[j]<=r){
                if(t==1){
                    if(b[j]==l)b[j]=r;
                    else b[j]--;
                }
                else b[j]=r+l-b[j];
            }
        }
    }
    for(int i=1;i<=m;i++)
        cout<<ara[b[i]]<<' ';
}


#include<bits/stdc++.h>
using namespace std;

#define mx 100010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)cin>>ara[i];
    for(int i=1;i<=qu;i++)cin>>tt[i]>>lft[i]>>rgt[i];
    for(int i=1;i<=m;i++)cin>>b[i];

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            int t=tt[i],l=lft[i],r=rgt[i];
            if(b[j]>=l and b[j]<=r){
                if(t==1){
                    if(b[j]==l)b[j]=r;
                    else b[j]--;
                }
                else b[j]=r+l-b[j];
            }
        }
    }
    for(int i=1;i<=m;i++)
        cout<<ara[b[i]]<<' ';
}


#include<bits/stdc++.h>
using namespace std;

#define mx 200010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)scanf("%d",&ara[i]);
    for(int i=1;i<=qu;i++)scanf("%d %d %d",&tt[i],&lft[i],&rgt[i]);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]);

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            int t=tt[i],l=lft[i],r=rgt[i];
            if(b[j]>=l and b[j]<=r){
                if(t==1){
                    if(b[j]==l)b[j]=r;
                    else b[j]--;
                }
                else b[j]=r+l-b[j];
            }
        }
    }
    for(int i=1;i<=m;i++)
        printf("%d",&ara[b[i]]);
}


#include<bits/stdc++.h>
using namespace std;

#define mx 200010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)scanf("%d",&ara[i]);
    for(int i=1;i<=qu;i++)scanf("%d %d %d",&tt[i],&lft[i],&rgt[i]);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]);

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            int t=tt[i],l=lft[i],r=rgt[i];
            if(b[j]>=l and b[j]<=r){
                if(t==1){
                    if(b[j]==l)b[j]=r;
                    else b[j]--;
                }
                else b[j]=r+l-b[j];
            }
        }
    }
    for(int i=1;i<=m;i++)
        printf("%d",ara[b[i]]);
}


#include<bits/stdc++.h>
using namespace std;

#define mx 200010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)scanf("%d",&ara[i]);
    for(int i=1;i<=qu;i++)scanf("%d %d %d",&tt[i],&lft[i],&rgt[i]);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]);

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            int t=tt[i],l=lft[i],r=rgt[i];
            if(b[j]>=l and b[j]<=r){
                if(t==1){
                    if(b[j]==l)b[j]=r;
                    else b[j]--;
                }
                else b[j]=r+l-b[j];
            }
        }
    }
    for(int i=1;i<=m;i++)
        printf("%d ",ara[b[i]]);
}


#include<bits/stdc++.h>
using namespace std;

#define mx 100010
int ara[mx],tt[mx],lft[mx],rgt[mx],b[110];

int main()
{
    int n,qu,m;
    cin>>n>>qu>>m;

    for(int i=1;i<=n;i++)cin>>ara[i];
    for(int i=1;i<=qu;i++)cin>>tt[i]>>lft[i]>>rgt[i];
    for(int i=1;i<=m;i++)cin>>b[i];

    for(int i=qu;i>=1;i--){
        for(int j=1;j<=m;j++){
            if(b[j]>=lft[i] and b[j]<=rgt[i]){
                if(tt[i]==1){
                    if(b[j]==lft[i]) b[j]=rgt[i];
                    else b[j]--;
                }
                else{
                    b[j]=rgt[i]-(b[j]-lft[i]);
                }
            }
        }
    }
    for(int i=1;i<=m;i++)
        cout<<ara[b[i]]<<' ';
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
typedef pair<double, double> PDD;

const int maxlongint = 2147483647;
const int biglongint = 2139062143;

#define LL long long
#define ULL unsigned long long
#define w1 first
#define w2 second
#define p_b push_back
#define m_p make_pair
#define l_b lower_bound

const int maxn = 200005;

int N, Q, M;
int a[maxn], b[105], t[maxn], l[maxn], r[maxn];

int main()
{
	scanf("%d %d %d", &N, &Q, &M);
	for (int i = 1; i <= N; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= Q; i++) scanf("%d %d %d", &t[i], &l[i], &r[i]);
	for (int i = 1; i <= M; i++) scanf("%d", &b[i]);
	for (int i = Q; i >= 1; i--)
	{
		if (t[i] == 1)
		{
			// Rotate
			for (int j = 1; j <= M; j++)
			{
				if (b[j] == l[i]) b[j] = r[i]; else
				if ((b[j] > l[i]) && (b[j] <= r[i])) --b[j];
			}
		}
		else
		{
			// Reverse
			for (int j = 1; j <= M; j++)
				if ((b[j] >= l[i]) && (b[j] <= r[i]))
					b[j] = l[i] + r[i] - b[j];
		}
	}
	for (int i = 1; i <= M; i++) printf("%d ", a[b[i]]); printf("\n");

	return 0;
}


#include <bits/stdc++.h>

#define FOR(x, a, b) for (int x = a; x <= b; ++x)
#define FOD(x, a, b) for (int x = a; x >= b; --x)
#define REP(x, a, b) for (int x = a; x < b; ++x)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A, n) { cout << #A << " = "; FOR(_, 1, n) cout << A[_] << " "; cout << endl; }
#define PR0(A, n)  { cout << #A << " = "; REP(_, 0, n) cout << A[_] << " "; cout << endl; }

using namespace std;

typedef long long LL;

const int N = 2e5 + 10;

int n, q, m;
int a[N];

struct Query {
    int t, l, r;
    Query () {}
    Query (int t, int l, int r) : t(t), l(l), r(r) {}
} Q[N];

int Ask(int ID) {
    FOD(i, q, 1) {
        int t = Q[i].t, l = Q[i].l, r = Q[i].r;
        if (l <= ID && ID <= r) {
            if (t == 1) ID = ID == l ? r : ID - 1;
                else ID = l + r - ID;
        }
    }
    return a[ID];
}

int main() {
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    scanf("%d%d%d", &n, &q, &m);
    FOR(i, 1, n) scanf("%d", &a[i]);
    FOR(i, 1, q) {
        int t, l, r; scanf("%d%d%d", &t, &l, &r);
        Q[i] = Query(t, l, r);
    }
    while (m--) {
        int k; scanf("%d", &k);
        printf("%d ", Ask(k));
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;

typedef long long ll;
const int mod=1e9+7;
#define mem(s,v) memset(s,v,sizeof(s))
#define inf 0x3f3f3f3f
#define maxn 200010
#define maxm 101

struct node{
	int id,num;
}a[maxn];

int vis[maxn],v[maxn];
int b[maxm];
int t[maxn],l[maxn],r[maxn];

int main()
{
	int n,q,m,i,j,k;
	mem(vis,0);
	scanf("%d%d%d",&n,&q,&m);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i].num);
		a[i].id=i;
	}
	for(i=0;i<q;++i) scanf("%d%d%d",&t[i],&l[i],&r[i]);
	for(i=0;i<m;++i){
		scanf("%d",&b[i]);
		if(vis[b[i]]) printf("%d ",a[v[b[i]]].num);
		else{
			vis[b[i]]=1;
			k=b[i];
			//cout<<k<<endl;
			for(j=q-1;j>=0;j--){
				if(t[j]==1){
					if(k-1==0 && n>=l[j] && n<=r[j]) k=n;
					else if(k-1>=l[j] && k-1<=r[j]) k=(k-1+n)%n;
				}
				else if(t[j]==2){
					if(k>=l[j] && k<=r[j]) k=l[j]+r[j]-k;
				}
				//cout<<k<<endl;
			}
			v[b[i]]=k;
			//cout<<endl;
			printf("%d ",a[k].num);
		}
		//if(i<m-1) printf(" ");
	}
	printf("\n");
	return 0;
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;

typedef long long ll;
const int mod=1e9+7;
#define mem(s,v) memset(s,v,sizeof(s))
#define inf 0x3f3f3f3f
#define maxn 200010
#define maxm 101

struct node{
	int id,num;
}a[maxn];

int vis[maxn],v[maxn];
int b[maxm];
int t[maxn],l[maxn],r[maxn];

int main()
{
	int n,q,m,i,j,k;
	mem(vis,0);
	mem(v,0);
	scanf("%d%d%d",&n,&q,&m);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i].num);
		a[i].id=i;
	}
	for(i=0;i<q;++i) scanf("%d%d%d",&t[i],&l[i],&r[i]);
	for(i=0;i<m;++i){
		scanf("%d",&b[i]);
		if(vis[b[i]]) printf("%d ",a[v[b[i]]].num);
		else{
			vis[b[i]]=1;
			k=b[i];
			//cout<<k<<endl;
			for(j=q-1;j>=0;j--){
				if(t[j]==1){
					if(k>=l[j] && k<=r[j]){
						if(k==l[j]) k=r[j];
						else k--;
					}
				}
				else if(t[j]==2){
					if(k>=l[j] && k<=r[j]) k=l[j]+r[j]-k;
				}
				//cout<<k<<endl;
			}
			v[b[i]]=k;
			//cout<<endl;
			printf("%d ",a[k].num);
		}
		//if(i<m-1) printf(" ");
	}
	printf("\n");
	return 0;
}

/*
6 4 5
1 2 3 4 5 6
2 1 3
2 3 6
1 1 6
1 3 5
2 2 1 5 3
*/


#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;

typedef long long ll;
const int mod=1e9+7;
#define mem(s,v) memset(s,v,sizeof(s))
#define inf 0x3f3f3f3f
#define maxn 200010
#define maxm 101

struct node{
	int id,num;
}a[maxn];

int vis[maxn],v[maxn];
int b[maxm];
int t[maxn],l[maxn],r[maxn];

int main()
{
	int n,q,m,i,j,k;
	mem(vis,0);
	mem(v,0);
	scanf("%d%d%d",&n,&q,&m);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i].num);
		a[i].id=i;
	}
	for(i=0;i<q;++i) scanf("%d%d%d",&t[i],&l[i],&r[i]);
	for(i=0;i<m;++i){
		scanf("%d",&b[i]);
		if(vis[b[i]]) printf("%d ",a[v[b[i]]].num);
		else{
			vis[b[i]]=1;
			k=b[i];
			//cout<<k<<endl;
			for(j=q-1;j>=0;j--){
				if(t[j]==1){
					if(k==1 && r[j]-l[j]+1>=l[j] && r[j]-l[j]+1<=r[j]) k=r[j]-l[j]+1;
					else if(k-1>=l[j] && k-1<=r[j]) k=k-1;
				}
				else if(t[j]==2){
					if(k>=l[j] && k<=r[j]) k=l[j]+r[j]-k;
				}
				//cout<<k<<endl;
			}
			v[b[i]]=k;
			//cout<<endl;
			printf("%d ",a[k].num);
		}
		//if(i<m-1) printf(" ");
	}
	printf("\n");
	return 0;
}

/*
6 4 5
1 2 3 4 5 6
2 1 3
2 3 6
1 1 6
1 1 5
2 2 1 5 3
*/


#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;

typedef long long ll;
const int mod=1e9+7;
#define mem(s,v) memset(s,v,sizeof(s))
#define inf 0x3f3f3f3f
#define maxn 200010
#define maxm 101

struct node{
	int id,num;
}a[maxn];

int vis[maxn],v[maxn];
int b[maxm];
int t[maxn],l[maxn],r[maxn];

int main()
{
	int n,q,m,i,j,k;
	mem(vis,0);
	scanf("%d%d%d",&n,&q,&m);
	for(i=1;i<=n;++i){
		scanf("%d",&a[i].num);
		a[i].id=i;
	}
	for(i=0;i<q;++i) scanf("%d%d%d",&t[i],&l[i],&r[i]);
	for(i=0;i<m;++i){
		scanf("%d",&b[i]);
		if(vis[b[i]]) printf("%d",a[v[b[i]]].num);
		else{
			vis[b[i]]=1;
			k=b[i];
			//cout<<k<<endl;
			for(j=q-1;j>=0;j--){
				if(t[j]==1){
					if(k-1==0 && n>=l[j] && n<=r[j]) k=n;
					else if((k-1+n)%n>=l[j] && (k-1+n)%n<=r[j]) k=(k-1+n)%n;
				}
				else if(t[j]==2){
					if(k>=l[j] && k<=r[j]) k=l[j]+r[j]-k;
				}
				//cout<<k<<endl;
			}
			v[b[i]]=k;
			//cout<<endl;
			printf("%d",a[k].num);
		}
		if(i<m-1) printf(" ");
	}
	printf("\n");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

const int N = 1048576;

int n, q, m, a[N];
int t[N], l[N], r[N];

int main() {
  cin >> n >> q >> m;
  for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for(int i = 0; i < q; i++) scanf("%d %d %d", &t[i], &l[i], &r[i]);
  for(int i = 0; i < m; i++) {
    int p;
    scanf("%d", &p);
    for(int j = q-1; j >= 0; j--)
      if(t[j] == 1) {
        if(l[j] == p) p = r[j];
        else if(l[j]<p && p<=r[j]) p -= 1;
      } else {
        if(l[j]<=p && p<=r[j]) p = r[j]-(p-l[j]);
      }
    printf("%d%c", a[p], i<m-1?' ':'\n');
  }
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

const int N = 1048576;

int n, q, m, a[N];
int t[N], l[N], r[N];

int main() {
  cin >> n >> q >> m;
  for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for(int i = 0; i < q; i++) scanf("%d %d %d", &t[i], &l[i], &r[i]);
  for(int i = 0; i < m; i++) {
    int p;
    scanf("%d", &p);
    for(int j = q-1; j >= 0; j--) if(l[j]<=p && p<=r[j])
      if(t[j] == 1) {
        p = p==l[j]? r[j]: p-1;
      } else {
        p = r[j]-(p-l[j]);
      }
    printf("%d%c", a[p], i<m-1?' ':'\n');
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> llp;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

int N, Q, M;
int arr[200000];
int marr[100];
stack<pair<int, ii> > S;

int main(int argc, char **argv) {
#ifdef LOCAL_PROJECT
	freopen("input", "r", stdin);
	freopen("output", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> Q >> M;
	for (int i = 0; i < N; i++) cin >> arr[i];
	while (Q--) {
		int a, b, c; cin >> a >> b >> c; b--; c--;
		S.push(mp(a, mp(b, c)));
	}
	for (int i = 0; i < M; i++) {
		int a; cin >> a; a--; marr[i] = a;
	}
	while (!S.empty()) {
		pair<int, ii> ext = S.top(); S.pop();
		int l = ext.second.first, r = ext.second.second;
		if (ext.first == 1) {
			for (int k = 0; k < M; k++) {
				if (marr[k] == l) marr[k] = r;
				else if (marr[k] > l && marr[k] <= r) marr[k] -= 1;
			}
		}
		else {
			for (int k = 0; k < M; k++) {
				if (marr[k] >= l && marr[k] <= r) {
					int ld = marr[k] - l, rd = r - marr[k];
					if (ld < rd) marr[k] = r - ld;
					else if (rd < ld) marr[k] = l + rd;
				}
			}
		}
	}
	for (int i = 0; i < M; i++) cout << arr[marr[i]] << " ";
	cout << endl;

	return 0;
}


// Codeforces-863D: Yet Another Array Queries Problem
// http://codeforces.com/problemset/problem/863/D

#include <cstdio>

using namespace std;

struct Query {
    int t;
    int l;
    int r;
};

int main() {
    int n = 0, q = 0, m = 0;
    int a[200010] = {0};
    Query query[200010];
    scanf("%d %d %d", &n, &q, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d", &query[i].t, &query[i].l, &query[i].r);
    }
    for (int i = 0; i < m; i++) {
        int b = 0;
        scanf("%d", &b);
        for (int j = q - 1; j >= 0; j--) {
            /*
            if (i == 0) {
                printf("[debug] prev_b: %d\t", b);
            }
            */
            if (b < query[j].l || b > query[j].r) {
                continue;
            }
            if (query[j].t == 1) {
                if (b == query[j].l) {
                    b = query[j].r;
                } else {
                    b -= 1;
                }
            } else {
                b = query[j].l + query[j].r - b;
            }
            /*
            if (i == 0) {
                printf("after_b: %d\n", b);
            }
            */
        }
        printf("%d%c", a[b], i == m - 1 ? '\n' : ' ');
    }
    return 0;
}


#include <cstdio>

using namespace std;

struct Query {
    int t;
    int l;
    int r;
};

int main() {
    int n = 0, q = 0, m = 0;
    int a[200010] = {0};
    Query query[200010];
    scanf("%d %d %d", &n, &q, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d", &query[i].t, &query[i].l, &query[i].r);
    }
    for (int i = 0; i < m; i++) {
        int b = 0;
        scanf("%d", &b);
        for (int j = q - 1; j >= 0; j--) {
            /*
            if (i == 0) {
                printf("[debug] prev_b: %d\t", b);
            }
            */
            if (b < query[j].l || b > query[j].r) {
                continue;
            }
            if (query[j].t == 1) {
                if (b == query[j].l) {
                    b = query[j].r;
                } else {
                    b -= 1;
                }
            } else {
                b = query[j].l + query[j].r - b;
            }
            /*
            if (i == 0) {
                printf("after_b: %d\n", b);
            }
            */
        }
        printf("%d%c", a[b], i == m - 1 ? '\n' : ' ');
    }
    return 0;
}


#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
using namespace std;
int n,m,q,a[200000],b[200000],i,t,l,r;
vector<int> ans;
struct node{
    int p,v,s;
    bool rev;
    node *l, *r;
    node(){
        p = rand(); v = 0;
        l = r = NULL;
        s = 1; rev = false;
    }
};
class treap{
public:
    int SIZE;
    node t[200000];
    node *root;
    void down(node *t){
        if(t == NULL || t -> rev == false) return;
        t -> rev = false;
        swap(t -> l, t -> r);
        if(t -> l != NULL) t -> l -> rev ^= true;
        if(t -> r != NULL) t -> r -> rev ^= true;
    }
    int getS(node *a){
        if(a == NULL) return 0;
        return a -> s;
    }
    void update(node *a){
        if(a == NULL) return;
        a -> s = getS(a -> l) + getS(a -> r) + 1;
    }
    node *Merge(node *a, node *b){
        if(a == NULL || b == NULL)
            return (a == NULL)? b:a;
        if(a -> p > b -> p){
            down(a);
            a -> r = Merge(a -> r, b);
            update(a);
            return a;
        }
        else{
            down(b);
            b -> l = Merge(a, b -> l);
            update(b);
            return b;
        }
    }
    void split(node *t, int k, node *&a, node *&b){
        if(t == NULL){
            a = b = NULL;
            return;
        }
        down(t);
        if(getS(t -> l) < k){
            split(t -> r, k - getS(t -> l) - 1, t -> r, b);
            a = t;
        }
        else{
            split(t -> l, k, a, t -> l);
            b = t;
        }
        update(a);
        update(b);
    }
    int add(int x){
        t[SIZE].v = x;
        t[SIZE].s = 1;
        root = Merge(root, &t[SIZE]);
        SIZE++;
    }
    void dfs(node *a){
        if(a == NULL) return;
        dfs(a -> l);
        ans.push_back(a -> v);
        dfs(a -> r);
    }
    void Shift(int l,int r){
        node *t1, *t2, *t3, *t4;
        t1 = t2 = t3 = t4 = NULL;
        split(root, r, t2, t3);
        split(t2, l - 1, t1, t2);
        split(t2, r - l, t2, t4);
        root = Merge(Merge(t1, Merge(t4, t2)), t3);
    }
    void Revolution(int l,int r){
        node *t1, *t2, *t3;
        split(root, r, t2, t3);
        split(t2, l - 1, t1, t2);
        t2 -> rev ^= true;
        root = Merge(t1, Merge(t2, t3));
    }
}d;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(time(0));
    cin >> n >> q >> m;
    for(i=0; i<n; i++){
        cin >> a[i];
        d.add(a[i]);
    }
    for(i=0; i<q; i++){
        cin >> t >> l >> r;
        if(t == 1) d.Shift(l, r);
        else d.Revolution(l, r);
    }
    d.dfs(d.root);
    for(i=0; i<m; i++){
        cin >> b[i];
        cout << ans[b[i] - 1] << " ";
    }
    return 0;
}


#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
using namespace std;
int n,m,q,a[200000],b[200000],i,t,l,r;
vector<int> ans;
struct node{
    int p,v,s;
    bool rev;
    node *l, *r;
    node(){
        p = rand(); v = 0;
        l = r = NULL;
        s = 1; rev = false;
    }
};
class treap{
public:
    int SIZE;
    node t[200000];
    node *root;
    void down(node *t){
        if(t == NULL || t -> rev == false) return;
        t -> rev = false;
        swap(t -> l, t -> r);
        if(t -> l != NULL) t -> l -> rev ^= true;
        if(t -> r != NULL) t -> r -> rev ^= true;
    }
    int getS(node *a){
        if(a == NULL) return 0;
        return a -> s;
    }
    void update(node *a){
        if(a == NULL) return;
        a -> s = getS(a -> l) + getS(a -> r) + 1;
    }
    node *Merge(node *a, node *b){
        if(a == NULL || b == NULL)
            return (a == NULL)? b:a;
        if(a -> p > b -> p){
            down(a);
            a -> r = Merge(a -> r, b);
            update(a);
            return a;
        }
        else{
            down(b);
            b -> l = Merge(a, b -> l);
            update(b);
            return b;
        }
    }
    void split(node *t, int k, node *&a, node *&b){
        if(t == NULL){
            a = b = NULL;
            return;
        }
        down(t);
        if(getS(t -> l) < k){
            split(t -> r, k - getS(t -> l) - 1, t -> r, b);
            a = t;
        }
        else{
            split(t -> l, k, a, t -> l);
            b = t;
        }
        update(a);
        update(b);
    }
    int add(int x){
        t[SIZE].v = x;
        t[SIZE].s = 1;
        root = Merge(root, &t[SIZE]);
        SIZE++;
    }
    void dfs(node *a){
        if(a == NULL) return;
        down(a);
        dfs(a -> l);
        ans.push_back(a -> v);
        dfs(a -> r);
    }
    void Shift(int l,int r){
        node *t1, *t2, *t3, *t4;
        t1 = t2 = t3 = t4 = NULL;
        split(root, r, t2, t3);
        split(t2, l - 1, t1, t2);
        split(t2, r - l, t2, t4);
        root = Merge(Merge(t1, Merge(t4, t2)), t3);
    }
    void Revolution(int l,int r){
        node *t1, *t2, *t3;
        split(root, r, t2, t3);
        split(t2, l - 1, t1, t2);
        t2 -> rev ^= true;
        root = Merge(t1, Merge(t2, t3));
    }
}d;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(time(0));
    cin >> n >> q >> m;
    for(i=0; i<n; i++){
        cin >> a[i];
        d.add(a[i]);
    }
    for(i=0; i<q; i++){
        cin >> t >> l >> r;
        if(t == 1) d.Shift(l, r);
        else d.Revolution(l, r);
    }
    d.dfs(d.root);
    for(i=0; i<m; i++){
        cin >> b[i];
        cout << ans[b[i] - 1] << " ";
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#define LL long long
#define maxn 200005
#define getsize(p) (p?p->size:0)
using namespace std;
int n,q,m,top;
struct Node{
    int key,cntk,size;
    bool tag;
    Node *ls,*rs;
}pool[maxn];
Node *rt;
void update(Node*& p){
    p->size=getsize(p->ls)+getsize(p->rs)+p->cntk;
}
void pushdown(Node*& p){
    if(p->tag==0) return;
    if(p->ls) p->ls->tag^=1;
    if(p->rs) p->rs->tag^=1;
    swap(p->ls,p->rs);
    p->tag=0;
    update(p);
}
Node *buildT(int x){
    Node *p=pool+(++top);
    p->key=x;
    p->cntk=p->size=1;
    return p;
}
void rrotate(Node*& p){
    Node *np=p->ls;
    p->ls=np->rs;
    np->rs=p;
    update(p);
    p=np;
    update(p);
}
void lrotate(Node*& p){
    Node *np=p->rs;
    p->rs=np->ls;
    np->ls=p;
    update(p);
    p=np;
    update(p);
}
void splay(Node*& p,int rk){
    pushdown(p);
    if(rk==getsize(p->ls)) return;
    else if(rk<getsize(p->ls)){
        pushdown(p->ls);
        if(rk==getsize(p->ls->ls)) rrotate(p);
        else if(rk<getsize(p->ls->ls)){
            splay(p->ls->ls,rk);
            rrotate(p);
            rrotate(p);
        }
        else{
            rk-=getsize(p->ls->ls)+p->cntk;
            splay(p->ls->rs,rk);
            lrotate(p->ls);
            rrotate(p);
        }
    }
    else{
        rk-=getsize(p->ls)+p->cntk;
        pushdown(p->rs);
        if(rk==getsize(p->rs->ls)) lrotate(p);
        else if(rk>getsize(p->rs->ls)){
            rk-=getsize(p->rs->ls)+p->cntk;
            splay(p->rs->rs,rk);
            lrotate(p);
            lrotate(p);
        }
        else{
            splay(p->rs->ls,rk);
            rrotate(p->rs);
            lrotate(p);
        }
    }
}
void insert(Node*& p,int rk,int x){
	if(!p) p=buildT(x);
	else{
		if(rk>getsize(p->ls)) insert(p->rs,rk-getsize(p->ls)-p->cntk,x);
		else insert(p->ls,rk,x);
		update(p);
	}
}
void reverse(int l,int r){
    if(l>=r) return;
    splay(rt,l-1);
    splay(rt->rs,r-l+1);
    rt->rs->ls->tag^=1;
}
void dfs(Node *p){
    if(p->tag==0) return;
    pushdown(p);
}
int main(){
    scanf("%d%d%d",&n,&q,&m);
    int a,b,c,opt;
    insert(rt,0,0);
    insert(rt,n+1,n+1);
    for(int i=1;i<=n;i++){
    	scanf("%d",&a);
    	insert(rt,i,a);
    	//cout<<"********";
    	splay(rt,i);

    }
    while(q--){
        cin>>opt;
        scanf("%d%d",&a,&b);
        if(opt==1){
        	reverse(a,b);
        	reverse(a+1,b);
        }
        else if(opt==2){
            reverse(a,b);
        }
    }
    for(int i=1;i<=m;i++){
    	scanf("%d",&a);
    	splay(rt,a);
    	cout<<rt->key<<" ";
    }
    return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

int n,m,q;

int niz[200005];

pair <int, pair <int,int> > upit[200005];

int nizek[105];

int main() {
	cin >> n >> q >> m;
	for (int i=0;i<n;i++) {
		scanf("%d", &niz[i]);
	}
	for (int i=0;i<q;i++) {
		scanf("%d%d%d", &upit[i].first, &upit[i].second.first, &upit[i].second.second);
	}
	for (int i=0;i<m;i++) {
		scanf("%d", &nizek[i]);
	}
	int x;
	int a,b,c;
	for (int i=0;i<m;i++) {
		x = nizek[i];
		for (int j=q-1;j>=0;j--) {
			a = upit[j].first;
			b = upit[j].second.first;
			c = upit[j].second.second;
			if (b > x || c < x) continue;
			if (a == 1) {
				if (x != b) {
					x = x-1;
				}
				else x = c;
			}
			else {
				x = (b+c) - x;
			}
		}
		printf("%d ", niz[x-1]);
	}
	return 0;
}


#include <iostream>
#include <cstdio>

using namespace std;

int n,m,q;

int niz[100005];

pair <int, pair <int,int> > upit[100005];

int nizek[105];

int main() {
	cin >> n >> q >> m;
	for (int i=0;i<n;i++) {
		scanf("%d", &niz[i]);
	}
	for (int i=0;i<q;i++) {
		scanf("%d%d%d", &upit[i].first, &upit[i].second.first, &upit[i].second.second);
	}
	for (int i=0;i<m;i++) {
		scanf("%d", &nizek[i]);
	}
	int x;
	int a,b,c;
	for (int i=0;i<m;i++) {
		x = nizek[i];
		for (int j=q-1;j>=0;j--) {
			a = upit[j].first;
			b = upit[j].second.first;
			c = upit[j].second.second;
			if (b > x || c < x) continue;
			if (a == 1) {
				if (x != b) {
					x = x-1;
				}
				else x = c;
			}
			else {
				x = (b+c) - x;
			}
		}
		printf("%d ", niz[x-1]);
	}
	return 0;
}


#include <bits/stdc++.h>
#define largo 200008

using namespace std ;

struct nodo {
	int etiqueta , tam , priori ;
	nodo *izq , *der ;
	int propaga ;
	nodo(){}
	nodo ( int e , int t , int p ) {
		etiqueta = e ;
		tam = t ;
		priori = p ;
		izq = der = NULL ;
		propaga = 0 ;
	}
	nodo ( int e , int t , int p , nodo *i , nodo *d ) {
		etiqueta = e ;
		tam = t ;
		priori = p ;
		izq = i ;
		der = d ;
		propaga = 0 ;
	}
	void reversear(){
		propaga ++ ;
		propaga &= 1 ;
	}
};

typedef nodo* pnodo ;

void propaga ( pnodo nodo ) {
	if ( ! nodo ) {
		///no exista nodo
		return ;
	}
	if ( nodo -> propaga ) {
		nodo -> propaga = 0 ;
		pnodo LAux = nodo -> izq ;
		if ( nodo -> izq ) {
			nodo -> izq -> reversear () ;
		}
		if ( nodo -> der ) {
			nodo -> der -> reversear () ;
		}
		///intercambiar hijos
		nodo -> izq = nodo -> der ;
		nodo -> der = LAux ;
	}
}

void split ( pnodo nodoAct , pnodo & L , pnodo & R , int pos , int acum ) {
	propaga ( nodoAct ) ;
	if ( ! nodoAct ) {
		///se acabo arbol
		L = R = NULL ;
		return ;
	}
	//propaga ( nodoAct ) ;
	int nodoActPos = acum + ( ( nodoAct -> izq ) ? nodoAct -> izq -> tam : 0 ) + 1 ;
	if ( nodoActPos < pos ) {
		L = nodoAct ;
		split ( nodoAct -> der , nodoAct -> der , R , pos , nodoActPos ) ;
	}else{
		R = nodoAct ;
		split ( nodoAct -> izq , L , nodoAct -> izq , pos , acum ) ;
	}
	nodoAct -> tam = ( ( nodoAct -> izq ) ? nodoAct -> izq -> tam : 0 ) + ( ( nodoAct -> der ) ? nodoAct -> der -> tam : 0 ) + 1 ;
}

void mergeT ( pnodo & arbol , pnodo L , pnodo R ) {
	propaga ( L ) ;
	propaga ( R ) ;
	if ( ! L || ! R ) {
		///se acabe un arbol
		arbol = ( L ) ? L : R ;
		return ;
	}
	if ( L -> priori > R -> priori ) {
		///L va antes
		arbol = L ;
		mergeT ( L -> der , L -> der , R ) ;
	}else{
		arbol = R ;
		mergeT ( R -> izq , L , R -> izq ) ;
	}
	arbol -> tam = ( ( arbol -> izq ) ? arbol -> izq -> tam : 0 ) + ( ( arbol -> der ) ? arbol -> der -> tam : 0 ) + 1 ;
}

void insertarDerecha ( pnodo & nodoAct , int etiqueta , int priori ) {
	//propaga ( nodoAct ) ;
	if ( ! nodoAct ) {
		///se sale de arbol
		nodoAct = new nodo ( etiqueta , 1 , priori ) ;
		return ;
	}
	if ( nodoAct -> priori > priori ) {
		///tengo que bajar
		nodoAct -> tam ++ ;
		insertarDerecha ( nodoAct -> der , etiqueta , priori ) ;
	}else{
		///aqui mismo inserto
		pnodo nuevo = new nodo ( etiqueta , nodoAct -> tam + 1 , priori , nodoAct , NULL ) ;
		nodoAct = nuevo ;
	}
}

void giroCiclico ( pnodo raiz , int l , int r ) {
	pnodo izq = NULL , der = NULL , centroDer = NULL , centro = NULL , cumuloIzq = NULL , finDer = NULL ;
	split ( raiz , izq , centroDer , l , 0 ) ;
	split ( centroDer , centro , der , r - l + 2 , 0 ) ;
	int fin = r - l + 1 ;
	split ( centro , cumuloIzq , finDer , fin , 0 ) ;
	mergeT ( centro , finDer , cumuloIzq ) ;
	mergeT ( centroDer , centro , der ) ;
	mergeT ( raiz , izq , centroDer ) ;
}

void reversear ( pnodo raiz , int l , int r ) {
	pnodo izq = NULL , der = NULL , centroDer = NULL , centro = NULL ;
	split ( raiz , izq , centroDer , l , 0 ) ;
	split ( centroDer , centro , der , r - l + 2 , 0 ) ;
	if ( centro ) {
		centro -> reversear () ;///what the fuck
	}else{
		printf ( "raro: %d %d %d %d %d %d %d\n" , l , r , (raiz) ? raiz -> tam : 0 , (izq) ? izq -> tam : 0 , (der) ? der -> tam : 0  , (centroDer) ? centroDer -> tam : 0  , (centro) ? centro -> tam : 0  ) ;
		return ;
	}
	mergeT ( centroDer , centro , der ) ;
	mergeT ( raiz , izq , centroDer ) ;
	/*split ( raiz , izq , der , l , 0 ) ;
	der -> reversear();
	mergeT ( raiz , izq , der ) ;  */
}

int arrFinal [ largo ] , tope = 0 ;

void generarArregloFinal ( pnodo nodoAct ) {
	propaga ( nodoAct ) ;
	if ( ! nodoAct ) {
		return ;
	}
	generarArregloFinal ( nodoAct -> izq ) ;
	arrFinal [ ++ tope ] = nodoAct -> etiqueta ;
	generarArregloFinal ( nodoAct -> der ) ;
}

int main()
{
	srand ( time ( NULL ) ) ;
	int N , Q , M ;
	scanf ( "%d %d %d" , &N , &Q , &M ) ;
	pnodo raiz = NULL ;
	int x ;
	for ( int i = 1 ; i <= N ; i ++ ) {
		scanf ( "%d" , &x ) ;
		insertarDerecha ( raiz , x , rand () ) ;
	}
	int com , l , r ;
	while ( Q -- ) {
		scanf ( "%d %d %d" , &com , &l , &r ) ;
		if ( l > r ) {
			l ^= r ;
			r ^= l ;
			l ^= r ;
		}
		if ( com == 1 ) {
			giroCiclico ( raiz , l , r ) ;
		}else{
			reversear ( raiz , l , r ) ;
		}
	}
	generarArregloFinal ( raiz ) ;
	while ( M -- ) {
		scanf ( "%d" , &x ) ;
		printf ( "%d " , arrFinal [ x ] ) ;
	}
	printf ( "\n" ) ;
	return 0 ;
}


#include <bits/stdc++.h>
#define largo 200008

using namespace std ;

struct nodo {
	int etiqueta , tam , priori ;
	nodo *izq , *der ;
	int propaga ;
	nodo(){}
	nodo ( int e , int t , int p ) {
		etiqueta = e ;
		tam = t ;
		priori = p ;
		izq = der = NULL ;
		propaga = 0 ;
	}
	nodo ( int e , int t , int p , nodo *i , nodo *d ) {
		etiqueta = e ;
		tam = t ;
		priori = p ;
		izq = i ;
		der = d ;
		propaga = 0 ;
	}
	void reversear(){
		propaga ++ ;
		propaga &= 1 ;
	}
};

typedef nodo* pnodo ;

void propaga ( pnodo nodo ) {
	if ( ! nodo ) {
		///no exista nodo
		return ;
	}
	if ( nodo -> propaga ) {
		nodo -> propaga = 0 ;
		pnodo LAux = nodo -> izq ;
		if ( nodo -> izq ) {
			nodo -> izq -> reversear () ;
		}
		if ( nodo -> der ) {
			nodo -> der -> reversear () ;
		}
		///intercambiar hijos
		nodo -> izq = nodo -> der ;
		nodo -> der = LAux ;
	}
}

void split ( pnodo nodoAct , pnodo & L , pnodo & R , int pos , int acum ) {
	propaga ( nodoAct ) ;
	if ( ! nodoAct ) {
		///se acabo arbol
		L = R = NULL ;
		return ;
	}
	//propaga ( nodoAct ) ;
	int nodoActPos = acum + ( ( nodoAct -> izq ) ? nodoAct -> izq -> tam : 0 ) + 1 ;
	if ( nodoActPos < pos ) {
		L = nodoAct ;
		split ( nodoAct -> der , nodoAct -> der , R , pos , nodoActPos ) ;
	}else{
		R = nodoAct ;
		split ( nodoAct -> izq , L , nodoAct -> izq , pos , acum ) ;
	}
	nodoAct -> tam = ( ( nodoAct -> izq ) ? nodoAct -> izq -> tam : 0 ) + ( ( nodoAct -> der ) ? nodoAct -> der -> tam : 0 ) + 1 ;
}

void mergeT ( pnodo & arbol , pnodo L , pnodo R ) {
	if ( ! L || ! R ) {
		///se acabe un arbol
		arbol = ( L ) ? L : R ;
		return ;
	}
	propaga ( L ) ;
	propaga ( R ) ;
	if ( L -> priori > R -> priori ) {
		///L va antes
		arbol = L ;
		mergeT ( L -> der , L -> der , R ) ;
	}else{
		arbol = R ;
		mergeT ( R -> izq , L , R -> izq ) ;
	}
	arbol -> tam = ( ( arbol -> izq ) ? arbol -> izq -> tam : 0 ) + ( ( arbol -> der ) ? arbol -> der -> tam : 0 ) + 1 ;
}

void insertarDerecha ( pnodo & nodoAct , int etiqueta , int priori ) {
	//propaga ( nodoAct ) ;
	if ( ! nodoAct ) {
		///se sale de arbol
		nodoAct = new nodo ( etiqueta , 1 , priori ) ;
		return ;
	}
	if ( nodoAct -> priori > priori ) {
		///tengo que bajar
		nodoAct -> tam ++ ;
		insertarDerecha ( nodoAct -> der , etiqueta , priori ) ;
	}else{
		///aqui mismo inserto
		pnodo nuevo = new nodo ( etiqueta , nodoAct -> tam + 1 , priori , nodoAct , NULL ) ;
		nodoAct = nuevo ;
	}
}

void giroCiclico ( pnodo raiz , int l , int r ) {
	pnodo izq = NULL , der = NULL , centroDer = NULL , centro = NULL , cumuloIzq = NULL , finDer = NULL ;
	split ( raiz , izq , centroDer , l , 0 ) ;
	split ( centroDer , centro , der , r - l + 2 , 0 ) ;
	int fin = r - l + 1 ;
	split ( centro , cumuloIzq , finDer , fin , 0 ) ;
	mergeT ( centro , finDer , cumuloIzq ) ;
	mergeT ( centroDer , centro , der ) ;
	mergeT ( raiz , izq , centroDer ) ;
}

void reversear ( pnodo raiz , int l , int r ) {
	pnodo izq = NULL , der = NULL , centroDer = NULL , centro = NULL ;
	split ( raiz , izq , centroDer , l , 0 ) ;
	split ( centroDer , centro , der , r - l + 2 , 0 ) ;
	if ( centro ) {
		centro -> reversear () ;///what the fuck
	}else{
		printf ( "query es: %d %d\n" , l , r ) ;
		return ;
	}
	mergeT ( centroDer , centro , der ) ;
	mergeT ( raiz , izq , centroDer ) ;
	/*split ( raiz , izq , der , l , 0 ) ;
	der -> reversear();
	mergeT ( raiz , izq , der ) ;  */
}

int arrFinal [ largo ] , tope = 0 ;

void generarArregloFinal ( pnodo nodoAct ) {
	propaga ( nodoAct ) ;
	if ( ! nodoAct ) {
		return ;
	}
	generarArregloFinal ( nodoAct -> izq ) ;
	arrFinal [ ++ tope ] = nodoAct -> etiqueta ;
	generarArregloFinal ( nodoAct -> der ) ;
}

int main()
{
	srand ( time ( NULL ) ) ;
	int N , Q , M ;
	scanf ( "%d %d %d" , &N , &Q , &M ) ;
	pnodo raiz = NULL ;
	int x ;
	for ( int i = 1 ; i <= N ; i ++ ) {
		scanf ( "%d" , &x ) ;
		insertarDerecha ( raiz , x , rand () ) ;
	}
	int com , l , r ;
	while ( Q -- ) {
		scanf ( "%d %d %d" , &com , &l , &r ) ;
		if ( l > r ) {
			l ^= r ;
			r ^= l ;
			l ^= r ;
		}
		if ( com == 1 ) {
			giroCiclico ( raiz , l , r ) ;
		}else{
			reversear ( raiz , l , r ) ;
		}
	}
	generarArregloFinal ( raiz ) ;
	while ( M -- ) {
		scanf ( "%d" , &x ) ;
		printf ( "%d " , arrFinal [ x ] ) ;
	}
	printf ( "\n" ) ;
	return 0 ;
}