#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 ) {
	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 () ;
	}
	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 ( 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 ) {
	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\n" , (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 <stdio.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 <stdio.h>
#include<cstdlib>
#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 navega ( pnodo nodoAct ) {
	if ( ! nodoAct ) {
		return ;
	}
	navega ( nodoAct -> izq ) ;
	printf ( "eh: %d ", nodoAct -> etiqueta ) ;
	navega ( nodoAct -> der ) ;
}

void imprimir ( pnodo nodo ) {
	printf ( "treap:\n" ) ;
	navega ( nodo ) ;
	printf ( "\n" ) ;
}*/

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 ) ;
	//imprimir ( cumuloIzq ) ;
	//imprimir ( finDer ) ;
	/*if ( ! finDer ) {
		printf ( "eh\n" ) ;
		return raiz ;
	}*/
	//insertarIzquierda ( cumuloIzq , finDer -> etiqueta , finDer -> priori ) ;
	mergeT ( centro , finDer , cumuloIzq ) ;
	//printf ( "queso: " ) ;
	//imprimir ( cumuloIzq ) ;
	//printf ( "queso2: " ) ;
	//imprimir ( der ) ;
	mergeT ( centroDer , centro , der ) ;
	//imprimir ( centroDer ) ;
	//imprimir ( izq ) ;
	mergeT ( raiz , izq , centroDer ) ;
	//printf ( "chanclas\n" ) ;
	//imprimir ( raiz ) ;
	//return raiz ;
}

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 ;
	//printf ("%d\n" , 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 ) ;
			//printf ( "what the fuck\n" ) ;
			//imprimir ( raiz ) ;
		}else{
			reversear ( raiz , l , r ) ;
		}
	}
	generarArregloFinal ( raiz ) ;
	while ( M -- ) {
		scanf ( "%d" , &x ) ;
		printf ( "%d " , arrFinal [ x ] ) ;
	}
	printf ( "\n" ) ;
	return 0 ;
}


#include <stdio.h>
#include<cstdlib>
#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 ) {
	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 ) ;
	centro -> reversear () ;
	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 ( 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 ) {
	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 ( "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 ;
}


#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 ( "tu mama\n" ) ;
		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 ;
}


// In the name of God
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>

using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;
int n , q , m , a[maxn] , b[110] , l[maxn] , r[maxn] , t[maxn];
int main()
{
  cin >> n >> q >> m;
  for (int  i = 1 ; i <= n ; i++)
    cin >> a[i];
  for (int i = 0 ; i < q ; i++)
    cin >> t[i] >> l[i] >> r[i];
  for (int i = 1 ; i <= m ; i++)
    cin >> b[i];
  for (int i = 1 ; i <= m ; i++){
    int ref = b[i];
    for (int j = q - 1 ; j >= 0 ; j--){
      if (ref >= l[j] && ref <= r[j]){
	if (t[j] == 1){
	  if (ref == l[j])
	    ref = r[j];
	  else
	    ref = ref - 1;
	}else{
	  ref = r[j] - (ref - l[j]);
	}
      }
    }
    cout << a[ref] << ' ';
  }
  cout << endl;

}


#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int n,q,m;
int a[200007];
map<int,int>mp;
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++)
	{
		int t=0,l=0,r=0;
		scanf("%d%d%d",&t,&l,&r);
		if(t==1)
		{
			int ty=a[r];
			for(int i=r;i>l;i--)
			{
				a[i]=a[i-1];
			}
			a[l]=ty;
		}
		else
		{
			int c=l;
			int d=r;
			while(c<d)
			{
				swap(a[c],a[d]);
				c++;
				d--;
			}
		}
		/*
		for(int i=1;i<=n;i++)
		{
			cout<<a[i]<<" ";
		}
		cout<<endl;
		*/
	}
	for(int i=1;i<=n;i++)
	{
		mp[a[i]]=i;
	}
	for(int i=1;i<=m;i++)
	{
		int t=0;
		scanf("%d",&t);
		printf("%d ",a[t]);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
struct node
{
	int t;
	int l;
	int r;
}pool[200007];
int n,q,m;
int a[200007];
int w[107];
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",&pool[i].t,&pool[i].l,&pool[i].r);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&w[i]);
	}
	for(int i=q;i>=1;i--)
	{
		for(int j=1;j<=m;j++)
		{
			int t=pool[i].t;
			int l=pool[i].l;
			int r=pool[i].r;
			if(w[j]>r||w[j]<l)
			{
				continue;
			}
			if(t==1)
			{
				if(w[j]==l)
				{
					w[j]=r;//
				}
				else
				{
					w[j]--;
				}
			}
			else
			{
				w[j]=l+r-w[j];
			}
		}
	}
	for(int i=1;i<=m;i++)
	{
		printf("%d ",a[w[i]]);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
struct node
{
	int t;
	int l;
	int r;
}pool[200007];
int n,q,m;
int a[200007];
int w[107];
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",&pool[i].t,&pool[i].l,&pool[i].r);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&w[i]);
	}
	for(int i=q;i>=1;i--)
	{
		for(int j=1;j<=m;j++)
		{
			int t=pool[i].t;
			int l=pool[i].l;
			int r=pool[i].r;
			if(w[j]>r||w[j]<l)
			{
				continue;
			}
			if(t==1)
			{
				if(w[j]==l)
				{
					w[j]=r;
				}
				else
				{
					w[j]--;
				}
			}
			else
			{
				w[j]=l+r-w[j];
			}
		}
	}
	for(int i=1;i<=m;i++)
	{
		printf("%d ",a[w[i]]);
	}
	return 0;
}


#include<bits/stdc++.h>
#define LLI long long int
#define heap priority_queue
#define MAXN 200000+5
#define INF (1<<29)
using namespace std;
LLI ans;
LLI a[MAXN],b[MAXN];
LLI t[MAXN],l[MAXN],r[MAXN];
LLI N,Q,M;
int main()
{
	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>>b[i];
		for(int j=1;j<=N;j++)
			if(a[j]==b[i])
			{
				ans=j;
				break;
			}
		for(int j=1;j<=Q;j++)
		{
			if(ans>r[j]||l[j]>ans)
				continue;
			if(t[j]==1)
			{
				if(ans==r[j])
					ans=l[j];
				else
					ans++;
			}
			else if(t[j]==2)
				ans=r[j]-ans+l[j];
		}
		cout<<a[ans]<<" ";
	}
	return 0;
}
//321654


#include<bits/stdc++.h>
#define LLI long long int
#define heap priority_queue
#define MAXN 200000+5
#define INF (1<<29)
using namespace std;
LLI ans;
LLI a[MAXN],b[MAXN];
LLI t[MAXN],l[MAXN],r[MAXN];
LLI N,Q,M;
int main()
{
	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>>ans;
		for(int j=Q;j>=1;j--)
		{
			if(ans>r[j]||l[j]>ans)
				continue;
			if(t[j]==1)
			{
				if(ans==l[j])
					ans=r[j];
				else
					ans--;
			}
			else if(t[j]==2)
				ans=r[j]-ans+l[j];
		}
		cout<<a[ans]<<" ";
	}
	return 0;
}
//321654


#include<bits/stdc++.h>
#define LLI long long int
#define heap priority_queue
#define MAXN 200000+5
#define INF (1<<29)
using namespace std;
LLI ans;
LLI a[MAXN],b[MAXN];
LLI t[MAXN],l[MAXN],r[MAXN];
LLI N,Q,M;
int main()
{
	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>>b[i];
		for(int j=1;j<=N;j++)
			if(a[j]==b[i])
			{
				ans=j;
				break;
			}
		for(int j=Q;j>=1;j--)
		{
			if(ans>r[j]||l[j]>ans)
				continue;
			if(t[j]==1)
			{
				if(ans==l[j])
					ans=r[j];
				else
					ans--;
			}
			else if(t[j]==2)
				ans=r[j]-ans+l[j];
		}
		cout<<a[ans]<<" ";
	}
	return 0;
}
//321654


#include<bits/stdc++.h>
#define LLI long long int
#define heap priority_queue
#define MAXN 200000+5
#define INF (1<<29)
using namespace std;
LLI ans;
LLI mem[MAXN];
LLI a[MAXN],b[MAXN];
LLI t[MAXN],l[MAXN],r[MAXN];
LLI N,Q,M;
int main()
{
	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>>b[i];
		for(int j=1;j<=N;j++)
			if(a[j]==b[i])
			{
				ans=j;
				break;
			}
		if(mem[b[i]])
		{
			cout<<mem[b[i]]<<" ";
			continue;
		}
		for(int j=1;j<=Q;j++)
		{
			if(ans>r[j]||l[j]>ans)
				continue;
			if(t[j]==1)
			{
				if(ans==r[j])
					ans=l[j];
				else
					ans++;
			}
			else if(t[j]==2)
				ans=r[j]-(ans-l[j]);
		}
		cout<<ans<<" ";
		mem[b[i]]=ans;
	}
	return 0;
}
//432165


#include <bits/stdc++.h>
#define mp make_pair
#define ft first
#define sd second
#define ue printf("what?\n");
#define pb push_back
#define oo 0x3F3F3F3F
#define OO 0x3F3F3F3F3F3F3F3F
#define EPS 1e-9
#define maxn 200000
#define pi acos(-1)
#define mod 1000000007
#define mdc __gcd
#define N 200005
using namespace std;
typedef long long ll;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

int t[N], l[N], r[N], v[N], id[N];

main()
{
	int n, q, m, i, j;
	scanf("%d%d%d", &n, &q, &m);
	for(i=1; i<=n; i++)
		scanf("%d", &v[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", &id[i]);
	for(j=q-1; j>=0; j--)
		if(t[j] == 1)
			for(i=0; i<m; i++)
			{
				if(id[i] < l[j] || id[i] > r[j])
					continue;
				if(id[i] == l[j])
					id[i] = r[j];
				else
					id[i]--;
			}
		else
			for(i=0; i<m; i++)
				if(id[i] >= l[j] && id[i] <= r[j])
					id[i] = l[j] + (r[j] - id[i]);
	for(i=0; i<m; i++)
		printf("%d%c", v[id[i]], i == m-1 ? '\n' : ' ');
}


#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#define N 200001
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,q,m,a[N],t[N],l[N],r[N],b[101];
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 j=q;j>=1;j--)
	    if(l[j]<=b[i] && b[i]<=r[j])
	      b[i]=(t[j]==1)?(b[i]==l[j]?r[j]:b[i]-1):(l[j]+r[j]-b[i]);
	  }
	for(int i=1;i<=m;i++)printf("%d%c",a[b[i]],i==m?'\n':' ');return 0;
}


/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007; /// 1e9+7
const int MAX = 200005;     /// 1e5+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}

int n, q, m, a[MAX], b[111], t[MAX], l[MAX], r[MAX];
void rot(int l, int r){
    for(int i=1; i<=m; i++){
        if(b[i]>=l and b[i]<=r){
            if(b[i]==r) b[i]=l;
            else b[i]++;
        }
    }
}
void rev(int l, int r){
    for(int i=1; i<=m; i++){
        if(b[i]>=l and b[i]<=r){
            b[i]=l+r-b[i];
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    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>>b[i];
    for(int i=1; i<=q; i++){
        if(t[i]==1) rot(l[i],r[i]);
        else rev(l[i],r[i]);
    }
    for(int i=1; i<=m; i++) cout<<a[b[i]]<<" ";
    cout<<endl;
    return 0;
}


/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define endl "\n"
#define inf 1<<30
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ss stringstream
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define bit_cnt(mask) __builtin_popcount(mask)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1000000007; /// 1e9+7
const int MAX = 200005;     /// 1e5+5
ll bigmod(ll n, ll r)
{
    if(r==0) return 1;
    if(r==1) return n;
    if(r%2==0)
    {
        ll ret = bigmod(n, r/2);
        return ((ret%MOD) * (ret%MOD)) % MOD;
    }
    else return ((n%MOD) * (bigmod(n,r-1)%MOD)) % MOD;
}
ll modinverse(ll a){return bigmod(a,MOD-2)%MOD;}
ll lcm(ll a, ll b) {a=abs(a); b=abs(b); return (a/__gcd(a,b))*b;}
ll gcd(ll a, ll b) {a=abs(a); b=abs(b); if(!b) return a; return __gcd(b,a%b);}

int n, q, m, a[MAX], b[111], t[MAX], l[MAX], r[MAX];
void rot(int l, int r){
    for(int i=1; i<=m; i++){
        if(b[i]>=l and b[i]<=r){
            if(b[i]==l) b[i]=r;
            else b[i]--;
        }
    }
}
void rev(int l, int r){
    for(int i=1; i<=m; i++){
        if(b[i]>=l and b[i]<=r){
            b[i]=l+r-b[i];
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    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>>b[i];
    for(int i=q; i>=1; i--){
        if(t[i]==1) rot(l[i],r[i]);
        else rev(l[i],r[i]);
    }
    for(int i=1; i<=m; i++) cout<<a[b[i]]<<" ";
    cout<<endl;
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 200010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int x[N], y[N], z[N];

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int inp[N];
int ans[N];

int main(){
    int n, q, m;
    fastScan(n); fastScan(q); fastScan(m);
    for(int i = 1; i <= n; i++){
        fastScan(inp[i]);
    }
    for(int i = 1; i <= q; i++){
        fastScan(x[i]); fastScan(y[i]); fastScan(z[i]);
    }
    for(int i = 1; i <= m; i++){
        int idx; fastScan(idx);
        for(int j = q; j >= 1; j--){
            if(y[j] <= idx && z[j] >= idx){
                if(x[j] == 1){
                    idx--;
                    if(idx < y[j]) idx = z[j];
                }else {
                    idx = z[j] - (idx - y[j]);
                }
            }
        }
        ans[i] = inp[idx];
    }
    for(int i = 1; i <= m; i++){
        printf("%d%c", ans[i], (i == n ? '\n' : ' '));
    }
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 200010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

int x[N], y[N], z[N];

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int inp[N];
int ans[N];

int main(){
    int n, q, m;
    fastScan(n); fastScan(q); fastScan(m);
    for(int i = 1; i <= n; i++){
        fastScan(inp[i]);
    }
    for(int i = 1; i <= q; i++){
        fastScan(x[i]); fastScan(y[i]); fastScan(z[i]);
    }
    for(int i = 1; i <= m; i++){
        int idx; fastScan(idx);
        for(int j = q; j >= 1; j--){
            if(y[j] <= idx && z[j] >= idx){
                if(x[j] == 1){
                    idx--;
                    if(idx < 1) idx = n;
                }else {
                    idx = z[j] - (idx - y[j]);
                }
            }
        }
        ans[i] = inp[idx];
    }
    for(int i = 1; i <= m; i++){
        printf("%d%c", ans[i], (i == n ? '\n' : ' '));
    }
}


#include<bits/stdc++.h>

using namespace std;

// method : turn from back

const int MAXN = 200000 + 10;
const int MAXM = 100 + 10;

int N , Q , M , a[MAXN] , b[MAXM] , opt[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" , &opt[i] , &l[i] , &r[i]);
	}

	for(int i = 1;i <= M;i++){
		int tmp;
		scanf("%d" , &tmp);

		for(int num = Q ; num >= 1; num--){
			if(l[num] <= tmp && r[num] >= tmp){
				if(opt[num] == 1){
					if(tmp == l[num]) tmp = r[num];
					else tmp--;
				}

				else if(opt[num] == 2){
					tmp = r[num] - (tmp - l[num]);
				}
			}
		}

		cout << a[tmp] << " ";
		//replace
	}
	return 0;
}


#include <iostream>
#define VAL 200005

using namespace std;

int v[VAL], N, M, Q, i, j, poz;;
int op[VAL], a[VAL], b[VAL];

int main()
{
    cin >> N >> M >> Q;
    for (i=1; i<=N; i++)
      cin >> v[i];
    for (i=1; i<=M; i++)
      cin >> op[i] >> a[i] >> b[i];
    for (i=1; i<=Q; i++)
    {
        cin >> poz;
        for (j=M; j>=1; j--)
        {
            if (op[j]==1)
            {
                if (a[j]<=poz && poz<=b[j])
                {
                    poz--;
                    if (poz<a[j])
                      poz=b[j];
                }
            }
            else
            {
                if (a[j]<=poz && poz<=b[j])
                    poz=b[j]-(poz-a[j]);
            }
        }
        cout << v[poz] << " ";
    }
    return 0;
}


#include <iostream>
#define VAL 200005

using namespace std;

int v[VAL], N, M, Q, i, j, poz;;
int op[VAL], a[VAL], b[VAL];

int main()
{
    cin >> N >> M >> Q;
    for (i=1; i<=N; i++)
      cin >> v[i];
    for (i=1; i<=M; i++)
      cin >> op[i] >> a[i] >> b[i];
    for (i=1; i<=Q; i++)
    {
        cin >> poz;
        for (j=1; j<=M; j++)
        {
            if (op[j]==1)
            {
                if (a[j]<=poz && poz<=b[j])
                {
                    poz++;
                    if (poz>b[j])
                      poz=a[j];
                }
            }
            else
            {
                if (a[j]<=poz && poz<=b[j])
                    poz=b[j]-(poz-a[j]);
            }
        }
        cout << v[poz] << " ";
    }
    return 0;
}


#include <cstdio>
using namespace std;

const int lim = 2e5 + 5;

struct query
{
    int c, l, r;
};

int n, m, q, a[lim];
query k[lim];

int main()
{
    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", &k[i].c, &k[i].l, &k[i].r);
    while (m--)
    {
        int cur; scanf("%d", &cur);
        for (int i = q - 1; i >= 0; --i)
            if (k[i].l <= cur && cur <= k[i].r)
                if (k[i].c == 1)
                {
                    if (cur == k[i].l) cur = k[i].r;
                    else --cur;
                }
                else cur = k[i].r - cur + k[i].l;
        printf("%d ", a[cur]);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int n,q,m;
int a[maxn],ans[110];
struct node
{
    int t;
    int l;
    int r;
}e[maxn];
int main()
{
    while(~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",&e[i].t,&e[i].l,&e[i].r);
        }
        for(int i=0;i<m;i++)
        {
            int x;
            scanf("%d",&x);
            ans[i]=x;
            for(int j=q-1;j>=0;j--)
            {
                if(ans[i]<e[j].l||ans[i]>e[j].r)
                    continue;
                if(e[j].t==1)
                {
                    if(ans[i]>e[j].l)
                        ans[i]--;
                    else
                        ans[i]=e[j].r;
                }
                else
                {
                    ans[i]=e[j].l+e[j].r-ans[i];
                }
            }
        }
        for(int i=0;i<m-1;i++)
            printf("%d ",a[ans[i]]);
        printf("%d\n",a[ans[m-1]]);
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int op,l,r;
}node[200005];
int n,q,m,t,a[200005];
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",&node[i].op,&node[i].l,&node[i].r);
	while (m--)
	{
		scanf("%d",&t);
		for (int i=q; i>=1; i--)
			if (t>=node[i].l && t<=node[i].r)
			{
				if (node[i].op==1)
				{
					t=t-1;
					if (t==node[i].l-1) t=node[i].r;
				}
				else
					t=node[i].r-(t-node[i].l);
			}
		printf("%d ",a[t]);
	}
	printf("\n");
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n,q,m,a[200010],op[200010],l[200010],r[200010];
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",&op[i],&l[i],&r[i]);
	for (int cas=1;cas<=m;cas++)
	{
		int x;
		scanf("%d",&x);
		for (int i=q;i>=1;i--)
			if (l[i]<=x&&x<=r[i])
			{
				if (op[i]==1)
				{
					x--;
					if (x<l[i]) x=r[i];
				}
				else x=(l[i]+r[i])-x;
			}
		printf("%d",a[x]);
		if (cas==m) printf("\n");
		else printf(" ");
	}
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n,q,m,a[200010];
int main()
{
	scanf("%d%d%d",&n,&q,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	while (q--)
	{
		int op,l,r;
		scanf("%d%d%d",&op,&l,&r);
		if (op==1)
		{
			int tmp=a[r];
			for (int i=r;i>l;i--) a[i]=a[i-1];
			a[l]=tmp;
		}
		else
			for (int i=l;i<=(l+r)>>1;i++)
				swap(a[i],a[(l+r)-i]);
	}
	for (int i=1;i<=m;i++)
	{
		int x;
		scanf("%d",&x);
		printf("%d",a[x]);
		if (i==m) printf("\n");
		else printf(" ");
	}
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int n,q,m;
int a[200200];
int qlr[200200][3];
int pseudo(int v);
int main(){
	int i,j;
	cin>>n>>q>>m;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=q;i++)cin>>qlr[i][0]>>qlr[i][1]>>qlr[i][2];
	for(i=1;i<=m;i++){
		cin>>j;
		cout<<pseudo(j)<<' ';
	}
}
int pseudo(int v){
	int i,l,r,t;
	for(i=q;i>0;i--){
		l=qlr[i][1];r=qlr[i][2];
		if(v>=l && v<=r){
			if(qlr[i][0]==1){
				v--;
				if(v<l)v=r;
			}else{
				t=r-l;
				v=l+t-(v-l);
			}
		}
	}
	//cout<<'('<<v<<')';
	return a[v];
}


#include<bits/stdc++.h>
using namespace std;
typedef struct
{
    int t,l,r;
}Q;
int main()
{
    int n,q,m,i,a[200001];
    scanf("%d %d %d",&n,&q,&m);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    Q bit[200001];
    for(i=0;i<q;i++)
        scanf("%d %d %d",&bit[i].t,&bit[i].l,&bit[i].r);
    for(i=0;i<m;i++)
    {
        int b,j;
        scanf("%d",&b);
        for(j=q-1;j>=0;j--)
        {
            if(bit[j].t==1)
            {
                if(bit[j].l==b)
                    b=bit[j].r;
                else if(b>bit[j].l && b<=bit[j].r)
                    b--;
            }
            else if(b>=bit[j].l && b<=bit[j].r)
                b=(bit[j].l+bit[j].r-b);
            //printf("%d\n",b);
        }
        printf("%d ",a[b]);
    }
    printf("\n");
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>

#include <cstring>
#include <string>
#include <sstream>

#include <cmath>
#include <algorithm>
#include <ctime>
#include <cassert>

#include <queue>
#include <utility>
#include <set>
#include <stack>
#include <vector>
#include <map>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define ff first
#define ss second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 2e5 + 5;

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>q>>m;
    REP(i,1,n)cin>>arr[i];
    REP(i,1,q)cin>>t[i]>>l[i]>>r[i];
    REP(i,1,m)cin>>am[i];

    REP(i,1,m){
    	REV(j,q,1){
    		if(am[i] < l[j] || am[i] > r[j])continue;
    		if(t[j] == 1){
    			am[i]--;
    			if(am[i] < l[j])am[i] = r[j];
			}else{
				am[i] = l[j] + r[j] - am[i];
			}
		}
		cout << arr[am[i]] << " ";
	}
	cout << endl;

    return 0;
}


/*This is by Technical Bangla from University of Dhaka*/
#include <bits/stdc++.h>
using namespace std;

#define pi acos(-1.0)
#define e 2.7182818284590451
#define eps 1e-6
#define in_d(x) scanf("%d",&x)
#define nl printf("\n")
#define MAX 200100
#define Mod 1000000007
#define inf (((ll)1<<62)+(((ll)1<<62)-1))
#define UND 1e17
#define MOD(a,m) ((a)%(m)+(m))%(m)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
typedef long long int ll;
typedef unsigned long long int llu;

template <class T> T sqr(T x) {return x*x;}
template <class T> T distsqr(T x,T y,T a,T b) {return sqr(x-a)+sqr(y-b);}
double cosine_angle(double a,double b,double c) {return (double)(sqr(a)+sqr(b)-sqr(c))/((double)2.0*a*b);}

template <class T> T Maximum(T a, T b) {return a>b?a:b;}
template <class T> T Minimum(T a, T b) {return a<b?a:b;}
template <class T> T GCD(T a, T b) {if(!b) return a;return GCD(b,a%b);}
template <class T> void SWAP(T &a, T &b) {T temp=a;a=b;b=temp;return ;}
template <class T> T Sign(T a) {return a<0?-1:1;}
template <class T> T Addition(T a,T b,T mod) {a=MOD(a,mod);b=MOD(b,mod);return MOD(a+b,mod);}
template <class T> T Multiplication(T a,T b,T mod) {T sign=Sign(a)*Sign(b);a=MOD(a,mod);b=MOD(b,mod);ll l=sqrt(inf)+1;if(a<l&&b<l) return (a*b)%mod;if(a<b) SWAP(a,b);T product=0;while(b){if(b&1) product=Addition(product,a,mod);b>>=1;a=Addition(a,a,mod);}if(sign<0) return sign*(mod-product);return product;}
template <class T> T BigMod(T a,T n,T mod){if(!n) return (T)1%mod;ll power=BigMod(a,n>>1,mod);power%=mod;power=Multiplication(power,power,mod);if(n&1) power=Multiplication(power,a,mod);return power;}
template <class T> T ExtendedEuclid(T a,T b,T c) {if(!a) return 0;return (-b*ExtendedEuclid(b%a,a,c%a)+c)/a;}
template <class T> T ModInverse(T a,T m) {return MOD(ExtendedEuclid(a,m,(T)GCD(a,m)),m);}

struct S
{
    int type,l,r;
}query[MAX];

int n,q,num[MAX];

bool hRange(int a,int b,int c)
{
    return a<=b&&b<=c;
}

int Solving(int indx)
{
    int i,j;
    for(i=0;i<q;i++)
    {
        j=q-i-1;
        if(!hRange(query[j].l,indx,query[j].r)) continue;
        if(query[j].type==1)
        {
            indx--;
            if(indx<query[j].l) indx=query[j].r;
        }
        else indx=query[j].l+query[j].r-indx;
    }
    return num[indx];
}

int main()
{
    int i,indx,m;
    scanf("%d %d %d",&n,&q,&m);
    for(i=0;i<n;i++) scanf("%d",num+i);
    for(i=0;i<q;i++) scanf("%d %d %d",&query[i].type,&query[i].l,&query[i].r),query[i].l--,query[i].r--;
    for(i=0;i<m;i++)
    {
        scanf("%d",&indx);indx--;
        printf("%d ",Solving(indx));
    }nl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MAXN = 2e5+5;
const ll mod = 1e9+7;
const int inf = 0x3f3f3f3f;

template <class T>
inline bool read(T &ret) {
   char c; int sgn;
   if(c=getchar(),c==EOF) return 0; //EOF
   while(c!='-'&&(c<'0'||c>'9')) c=getchar();
   sgn=(c=='-')?-1:1;
   ret=(c=='-')?0:(c-'0');
   while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
   ret*=sgn;
   return 1;
}

int n, q, m, num[MAXN], l[MAXN], r[MAXN], op[MAXN], x;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    read(n), read(q), read(m);
    for(int i = 1; i <= n; ++i) read(num[i]);
    for(int i = 1; i <= q; ++i) read(op[i]), read(l[i]), read(r[i]);
    while(m--) {
        read(x);
        for(int i = q; i; --i) {
            if(l[i] <= x && r[i] >= x) {
                if(op[i] == 1) {
                    if(x == l[i]) x = r[i];
                    else x--;
                }
                else x = l[i] + r[i] - x;
            }
        }
        printf("%d ", num[x]);
    }

    return 0;
}


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

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
	#endif

	int n,q,m;
	cin>>n>>q>>m;

	int arr[n+1];
	for(int i=1;i<=n;i++){cin>>arr[i];}

	vector<pair<int,pair<int,int> > > v;
	for(int i=0;i<q;i++){
		int x,y,z;cin>>x>>y>>z;
		v.push_back(make_pair(x,make_pair(y,z)));
	}
	//cout<<"executed"<<endl;
	int mark[n+1];
	memset(mark,-1,sizeof(mark));
	//cout<<"executed"<<endl;
	while(m--){
		int x,x1;cin>>x;x1=x;
		if(mark[x] > 0){cout<<mark[x]<<" ";continue;}
		//cout<<"executed"<<endl;
		for(int i=q-1;i>=0;i--){
			int t=v[i].first,l=v[i].second.first,r=v[i].second.second;

			if(l<=x && r>=x){
				if(t==1){
					x--;
					if(x<=0){x=r;}
				}else{
					x = l+r-x;
				}
			}
		}
		mark[x1]=arr[x];
		cout<<arr[x]<<" ";
	}
	cout<<endl;
}


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

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
	#endif

	int n,q,m;
	cin>>n>>q>>m;

	int arr[n+1];
	for(int i=1;i<=n;i++){cin>>arr[i];}

	vector<pair<int,pair<int,int> > > v;
	for(int i=0;i<q;i++){
		int x,y,z;cin>>x>>y>>z;
		v.push_back(make_pair(x,make_pair(y,z)));
	}
	//cout<<"executed"<<endl;
	//cout<<"executed"<<endl;
	while(m--){
		int x,x1;cin>>x;x1=x;
		//cout<<"executed"<<endl;
		for(int i=q-1;i>=0;i--){
			int t=v[i].first,l=v[i].second.first,r=v[i].second.second;

			if(l<=x && r>=x){
				if(t==1){
					x--;
					if(x<l){x=r;}
				}else{
					x = l+r-x;
				}
			}
		}
		//mark[x1]=arr[x];
		cout<<arr[x]<<" ";
	}
	cout<<endl;
}


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

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
	#endif

	int n,q,m;
	cin>>n>>q>>m;

	int arr[n+1];
	for(int i=1;i<=n;i++){cin>>arr[i];}

	vector<pair<int,pair<int,int> > > v;
	for(int i=0;i<q;i++){
		int x,y,z;cin>>x>>y>>z;
		v.push_back(make_pair(x,make_pair(y,z)));
	}
	//cout<<"executed"<<endl;
	//cout<<"executed"<<endl;
	while(m--){
		int x,x1;cin>>x;x1=x;
		//cout<<"executed"<<endl;
		for(int i=q-1;i>=0;i--){
			int t=v[i].first,l=v[i].second.first,r=v[i].second.second;

			if(l<=x && r>=x){
				if(t==1){
					x--;
					if(x<=0){x=r;}
				}else{
					x = l+r-x;
				}
			}
		}
		//mark[x1]=arr[x];
		cout<<arr[x]<<" ";
	}
	cout<<endl;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#define LiangJiaJun main
#define pa pair<int,int>
#define INF 1999122700
using namespace std;
struct data{int p,l,r;}a[200004];
int n,b[200004],x,q,m;
int LiangJiaJun(){
    scanf("%d%d%d",&n,&q,&m);
    for(int i=1;i<=n;i++)scanf("%d",&b[i]);
    for(int i=1;i<=q;i++)scanf("%d%d%d",&a[i].p,&a[i].l,&a[i].r);
    for(int t=1;t<=m;t++){
        scanf("%d",&x);
        for(int i=q;i>=1;i--){
            if(!(a[i].l<=x&&x<=a[i].r))continue;
            if(a[i].p==1){
                if(x==a[i].l)x=a[i].r;
                else x--;
            }
            else x=a[i].r-x+a[i].l;
        }
        printf("%d ",b[x]);
    }
    puts("");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
	int key, value;
	Node *left, *right;

	Node(int key, int value) :
		key(key), value(value), left(NULL), right(NULL) {};
	Node(){};
};

Node *root[2], *tmp[2][2];
int M, N, a[300000], Q;

int get(Node *p) {
	if (p == NULL) return 0;
	else return p -> key;
}

Node *Update(Node *root) {
	root -> key = get(root -> left) + get(root -> right) + 1;
	return root;
}

Node *rightRotate(Node *x) {
	Node *y = x -> left;
	x -> left =  y -> right;
	y -> right = x;
	x = Update(x);
	y = Update(y);
	return y;
}

Node *leftRotate(Node *y) {
	Node *x = y -> right;
	y -> right = x -> left;
	x -> left = y;
	y = Update(y);
	x = Update(x);
	return x;
}

Node *Splay(Node *root, const int key) {
	int sz = get(root -> left) + 1;

	if (root == NULL || sz == key) return root;

	if (sz > key) {
		if (root -> left == NULL) return root;

		if (get(root -> left -> left) + 1 > key) {
			root -> left -> left = Splay(root -> left -> left, key);
			root = rightRotate(root);
		} else if (get(root -> left -> left) + 1 < key) {
			root -> left -> right = Splay(root -> left -> right, key - get(root -> left -> left) - 1);
			if (root -> left -> right != NULL)  root -> left = leftRotate(root -> left);
		}
		return (root -> left == NULL) ? root : rightRotate(root);

	} else {
		if (root -> right == NULL) return root;

		if (sz + get(root -> right -> left) + 1 > key) {
			root -> right -> left = Splay(root -> right -> left, key - sz);
			if (root -> right -> left != NULL) root -> right = rightRotate(root -> right);
		}
		else if (sz + get(root -> right -> left) + 1 < key){
			root -> right -> right = Splay(root -> right -> right, key - sz - get(root -> right -> left) - 1 );
			root = leftRotate(root);
		}
		return (root -> right == NULL) ? root : leftRotate(root);
	}
}

Node *put(Node *root, int key, int value) {
	if (root == NULL) return new Node(1, value);

	root = Splay(root, root -> key);

	Node *p = new Node(key, value);

	p -> left = root;
	p = Update(p);

	return p;
}

Node *Join(Node *root, Node *S) {
    if (root == NULL) return root = S;
	root = Splay(root, root -> key);
	root -> right = S;
	root = Update(root);
	return root;

}

Node *Split(Node *root, Node *&p, int key) {
    if (key == 0) {
        p = root;
        root = NULL;
        return root;
    }

    if (key == root -> key) {
        p = NULL;
        return root;
    }

	root = Splay(root, key);
	p = root -> right;
	root -> right = NULL;
	root = Update(root);
	p = Update(p);
	return root;
}

void Cut(int L, int R) {
    int _L = N - R + 1, _R = N - L + 1;
    tmp[0][0] = tmp[0][1] = NULL;
    tmp[1][0] = tmp[1][1] = NULL;

    root[0] = Split(root[0], tmp[0][0], R);
    root[0] = Split(root[0], tmp[0][1], L - 1);

    root[1] = Split(root[1], tmp[1][0], _R);
    root[1] = Split(root[1], tmp[1][1], _L - 1);

    root[0] = Join(root[0], tmp[1][1]); root[0] = Join(root[0], tmp[0][0]);
    root[1] = Join(root[1], tmp[0][1]); root[1] = Join(root[1], tmp[1][0]);
}

void Shift(int L, int R) {
  Node *tmp[3];
  root[0] = Split(root[0], tmp[0], R);
  root[0] = Split(root[0], tmp[1], R - 1);
  root[0] = Split(root[0], tmp[2], L - 1);
  root[0] = Join(root[0], tmp[1]);
  root[0] = Join(root[0], tmp[2]);
  root[0] = Join(root[0], tmp[0]);

  int _L = N - R + 1, _R = N - L + 1;
  L = _L; R = _R;
  root[1] = Split(root[1], tmp[0], R);
  root[1] = Split(root[1], tmp[1], R - 1);
  root[1] = Split(root[1], tmp[2], L - 1);
  root[1] = Join(root[1], tmp[1]);
  root[1] = Join(root[1], tmp[2]);
  root[1] = Join(root[1], tmp[0]);

}

int main() {
//	freopen("in.inp", "r", stdin);
	scanf("%d %d %d", &N, &Q, &M);
	for (int i  = 0; i < N; ++i) scanf("%d", &a[i]);

	root[0] = root[1] = NULL;
	for (int i = 0; i < N; ++i) {
		root[0] = put(root[0], 1, a[i]);
		root[1] = put(root[1], 1, a[N - i - 1]);
	}

	for (int i = 0; i < Q; ++i) {
		int q, L, R;
		scanf("%d %d %d", &q, &L, &R);
		if (q == 2)
			Cut(L, R);
		else
		  Shift(L, R);
	}

	for (int i = 0; i < M; ++i) {
	  int idx;
	  scanf("%d ", &idx);
	  root[0] = Splay(root[0], idx);
	  printf("%d ", root[0] -> value);
	}

}


#include <bits/stdc++.h>

using namespace std;

struct Node {
	int key, value;
	Node *left, *right;

	Node(int key, int value) :
		key(key), value(value), left(NULL), right(NULL) {};
	Node(){};
};

Node *root[2], *tmp[2][2];
int M, N, a[300000], Q;

int get(Node *p) {
	if (p == NULL) return 0;
	else return p -> key;
}

Node *Update(Node *root) {
	root -> key = get(root -> left) + get(root -> right) + 1;
	return root;
}

Node *rightRotate(Node *x) {
	Node *y = x -> left;
	x -> left =  y -> right;
	y -> right = x;
	x = Update(x);
	y = Update(y);
	return y;
}

Node *leftRotate(Node *y) {
	Node *x = y -> right;
	y -> right = x -> left;
	x -> left = y;
	y = Update(y);
	x = Update(x);
	return x;
}

Node *Splay(Node *root, const int key) {
	int sz = get(root -> left) + 1;

	if (root == NULL || sz == key) return root;

	if (sz > key) {
		if (root -> left == NULL) return root;

		if (get(root -> left -> left) + 1 > key) {
			root -> left -> left = Splay(root -> left -> left, key);
			root = rightRotate(root);
		} else if (get(root -> left -> left) + 1 < key) {
			root -> left -> right = Splay(root -> left -> right, key - get(root -> left -> left) - 1);
			if (root -> left -> right != NULL)  root -> left = leftRotate(root -> left);
		}
		return (root -> left == NULL) ? root : rightRotate(root);

	} else {
		if (root -> right == NULL) return root;

		if (sz + get(root -> right -> left) + 1 > key) {
			root -> right -> left = Splay(root -> right -> left, key - sz);
			if (root -> right -> left != NULL) root -> right = rightRotate(root -> right);
		}
		else if (sz + get(root -> right -> left) + 1 < key){
			root -> right -> right = Splay(root -> right -> right, key - sz - get(root -> right -> left) - 1 );
			root = leftRotate(root);
		}
		return (root -> right == NULL) ? root : leftRotate(root);
	}
}

Node *put(Node *root, int key, int value) {
	if (root == NULL) return new Node(1, value);

	root = Splay(root, root -> key);

	Node *p = new Node(key, value);

	p -> left = root;
	p = Update(p);

	return p;
}

Node *Join(Node *root, Node *S) {
    if (root == NULL) return root = S;
	root = Splay(root, root -> key);
	root -> right = S;
	root = Update(root);
	return root;

}

Node *Split(Node *root, Node *&p, int key) {
    if (key == 0) {
        p = root;
        root = NULL;
        return root;
    }

    if (key == root -> key) {
        p = NULL;
        return root;
    }

	root = Splay(root, key);
	p = root -> right;
	root -> right = NULL;
	root = Update(root);
	p = Update(p);
	return root;
}

void Cut(int L, int R) {
    int _L = N - R + 1, _R = N - L + 1;
    tmp[0][0] = tmp[0][1] = NULL;
    tmp[1][0] = tmp[1][1] = NULL;

    root[0] = Split(root[0], tmp[0][0], R);
    root[0] = Split(root[0], tmp[0][1], L - 1);

    root[1] = Split(root[1], tmp[1][0], _R);
    root[1] = Split(root[1], tmp[1][1], _L - 1);

    root[0] = Join(root[0], tmp[1][1]); root[0] = Join(root[0], tmp[0][0]);
    root[1] = Join(root[1], tmp[0][1]); root[1] = Join(root[1], tmp[1][0]);
}

void Shift(int L, int R) {
  Node *tmp[3];
  root[0] = Split(root[0], tmp[0], R);
  root[0] = Split(root[0], tmp[1], R - 1);
  root[0] = Split(root[0], tmp[2], L - 1);
  root[0] = Join(root[0], tmp[1]);
  root[0] = Join(root[0], tmp[2]);
  root[0] = Join(root[0], tmp[0]);

  int _L = N - R + 1, _R = N - L + 1;
  L = _L; R = _R;
  root[1] = Split(root[1], tmp[0], R);
  root[1] = Split(root[1], tmp[1], L);
  root[1] = Split(root[1], tmp[2], L - 1);
  root[1] = Join(root[1], tmp[1]);
  root[1] = Join(root[1], tmp[2]);
  root[1] = Join(root[1], tmp[0]);
}

int main() {
//	freopen("in.inp", "r", stdin);
	scanf("%d %d %d", &N, &Q, &M);
	for (int i  = 0; i < N; ++i) scanf("%d", &a[i]);

	root[0] = root[1] = NULL;
	for (int i = 0; i < N; ++i) {
		root[0] = put(root[0], 1, a[i]);
		root[1] = put(root[1], 1, a[N - i - 1]);
	}

	for (int i = 0; i < Q; ++i) {
		int q, L, R;
		scanf("%d %d %d", &q, &L, &R);
		if (q == 2)
			Cut(L, R);
		else
		  Shift(L, R);
	}

	for (int i = 0; i < M; ++i) {
	  int idx;
	  scanf("%d ", &idx);
	  root[0] = Splay(root[0], idx);
	  printf("%d ", root[0] -> value);
	}

}


#include<bits/stdc++.h>
#define PI acos(-1)
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define ull unsigned long long
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 200005
#define MXX -1
#define  s second
#define f first
#define mod 1000000007
#define inf 1000000007
#define eps 1e-15
//int ex[]={1,-1,0,0};
//int wye[]={0,0,1,-1};
using namespace std;
int n,q,m,a[MX],b[105],t[MX],l[MX],r[MX];
int main()
{
    fast();
    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--){
        for(int j=1;j<=m;j++){
            if(b[j]>=l[i] && b[j]<=r[i]){
                if(t[i]==1){
                    if(b[j]==l[i]) b[j]=r[i];
                    else b[j]--;
                }
                else{
                    b[j]=r[i]-(b[j]-l[i]);
                }
            }
        }
    }
    for(int i=1;i<=m;i++) printf("%d ",a[b[i]]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w;
int A[123456], B[123456], C[123456], D[123456], pos[123];

int Q;

int main ()
{
	scanf("%d %d %d", &n, &m, &Q);
	FOE(i, 1, n) scanf("%d", &A[i]);

	FOR(i, 0, m) scanf("%d %d %d", &B[i], &C[i], &D[i]);
	FOR(i, 0, Q) scanf("%d", &pos[i]);

	FOR(i, 0, Q)
	{
		x = pos[i];

		FOD(j, m - 1, 0)
		{
	//		printf("x = %d\n", x);

			if (x < C[j] || x > D[j]) continue;
			if (B[j] == 1)
			{
				if (x == C[j]) x = D[j];
				else x = x - 1;
			}
			else
			{
				x = D[j] - (x - C[j]);
			}
		}

	//	printf("x = %d\n", x);
		printf("%d ", A[x]);
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w;
int A[223456], B[223456], C[223456], D[223456], pos[123];

int Q;

int main ()
{
	scanf("%d %d %d", &n, &m, &Q);
	FOE(i, 1, n) scanf("%d", &A[i]);

	FOR(i, 0, m) scanf("%d %d %d", &B[i], &C[i], &D[i]);
	FOR(i, 0, Q) scanf("%d", &pos[i]);

	FOR(i, 0, Q)
	{
		x = pos[i];

		FOD(j, m - 1, 0)
		{
			if (x < C[j] || x > D[j]) continue;
			if (B[j] == 1)
			{
				if (x == C[j]) x = D[j];
				else x = x - 1;
			}
			else x = D[j] - (x - C[j]);
		}

	//	printf("x = %d\n", x);
		printf("%d ", A[x]);
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=5*100000+5;
int SIZ=0,rt=0,n,q,m,siz[maxn],val[maxn],prio[maxn],rev[maxn],ch[maxn][2],a[maxn];
int rd=1,Base=19260817,mo=2147483647;
int getrand()
{
    rd=(rd*Base+1)&mo;
    return rd;
}
int newnode(int valu)
{
    val[++SIZ]=valu;
    prio[SIZ]=getrand();
    siz[SIZ]=1;
    rev[SIZ]=0;
    return SIZ;
}
void pushup(int now){siz[now]=1+siz[ch[now][0]]+siz[ch[now][1]];}
void pushdown(int now)
{
    if(now && rev[now]){
        rev[now]=0;
        swap(ch[now][0],ch[now][1]);
        if(ch[now][0]) rev[ch[now][0]]^=1;
        if(ch[now][1]) rev[ch[now][1]]^=1;
    }
}
int merge(int x,int y)
{
    if(!x || !y) return x+y;
    pushdown(x),pushdown(y);
    if(prio[x]<prio[y]){
        ch[y][0]=merge(x,ch[y][0]);
        pushup(y);
        return y;
    }else{
        ch[x][1]=merge(ch[x][1],y);
        pushup(x);
        return x;
    }
}
void split(int now,int k,int &x,int &y)
{
    if(!now) x=y=0;
    else{
        pushdown(now);
        if(k<=siz[ch[now][0]])
            y=now,split(ch[now][0],k,x,ch[now][0]);
        else x=now,split(ch[now][1],k-siz[ch[now][0]]-1,ch[now][1],y);
        pushup(now);
    }
}
int kth(int now,int k)
{
    while(1){
        pushdown(now);
        if(k<=siz[ch[now][0]]) now=ch[now][0];
        else if(k==siz[ch[now][0]]+1) return now;
        else k-=siz[ch[now][0]]+1,now=ch[now][1];
    }
}
int build(int l,int r)
{
    if(l>r) return 0;
    int mid=(l+r)>>1;
    int now=newnode(a[mid]);
    ch[now][0]=build(l,mid-1);
    ch[now][1]=build(mid+1,r);
    pushup(now);
    return now;
}
void dfs(int now)
{
    if(!now) return;
    pushdown(now);
    dfs(ch[now][0]);
    printf("%d ",val[now]);
    dfs(ch[now][1]);
}
void getrev(int l,int r)
{
    int a=0,b=0,c=0,d=0;
    split(rt,r,a,b);
    split(a,l-1,c,d);
    rev[d]^=1;
    rt=merge(merge(c,d),b);
}
int main()
{
    //freopen("1.out","w",stdout);
    scanf("%d%d%d",&n,&q,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    rt=build(1,n);
    for(int i=1;i<=q;i++){
        //printf("i=%d\n",i);
        int typ,l,r;
        scanf("%d%d%d",&typ,&l,&r);
        if(typ==2) getrev(l,r);
        else{
            int a=0,b=0,c=0,d=0;
            split(rt,r,a,b);
            split(a,l-1,c,d);
            int lef=0,rgh=0;
            split(d,r-l,lef,rgh);
            rt=merge(merge(c,rgh),merge(lef,b));
        }
        //printf("tree:\n");
        //dfs(rt);puts("");
    }
    //printf("finish.\n");
    for(int i=1;i<=m;i++){
        int b;
        scanf("%d",&b);
        printf("%d\n",val[kth(rt,b)]);
    }
    return 0;
}


#include <iostream>

using namespace std;

long long a[500000];
int main ()
{
	int n,x,m = 0;
	cin >> n >> x;
	for(long long i = 1; i <= n; i++)
	{
		long long f;
		cin >> f;
		if(i <= 100000)
	{
			a[f] = 1;
	}
	}
	for(long long i = 1; i < 500000 and x >= i; i++)
	{
		if(a[i] == 0)
		{
			a[i] = 2;
			x -= i;
			m++;
		}

	}
	cout << m << "\n";
	for(long long i = 1; m > 0; i++)
	{
		if(a[i] == 2)
		{
			cout << i << " ";
			m--;
		}
	}
	return 0;
}


#include <iostream>

using namespace std;

long long n,x,a[500000],k = 0,m = 0;
int main ()
{
	cin >> n >> x;
	for(long long i = 1; i <= n; i++)
	{
		long long f;
		cin >> f;
		if(i <= 500000)
	{
			a[f] = 1;
	}
	}
	for(long long i = 1; i < 500000 and x >= i; i++)
	{
		if(a[i] == 0)
		{
			a[i] = 2;
			x -= i;
			m++;
		}

	}
	cout << m << "\n";
	for(long long i = 1; m > 0; i++)
	{
		if(a[i] == 2)
		{
			cout << i << " ";
			m--;
		}
	}
	return 0;
}


#include <iostream>

using namespace std;

long long a[500000];
int main ()
{
	int n,x,m = 0;
	cin >> n >> x;
	for(long long i = 1; i <= n; i++)
	{
		long long f;
		cin >> f;
		if(i <= 500000)
	{
			a[f] = 1;
	}
	}
	for(long long i = 1; i < 500000 and x >= i; i++)
	{
		if(a[i] == 0)
		{
			a[i] = 2;
			x -= i;
			m++;
		}

	}
	cout << m << "\n";
	for(long long i = 1; m > 0; i++)
	{
		if(a[i] == 2)
		{
			cout << i << " ";
			m--;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k=0,a[1000000]={0},sum=0,b[1000000],t=0,m,x;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>x;
        a[x]=1;

    }
    for(i=1;;i++)
    {
        if(sum>=m)
            break;
            else
            {
                if(a[i]!=1)
                {
                    sum=sum+i;
                    b[k]=i;
                    k++;
                    t++;
                }
            }
            if(sum>m)
            {
                sum=sum-i;
                k--;
                t--;
                break;
            }

    }
    cout<<t<<endl;
    for(i=0;i<k;i++)
    {
        cout<<b[i]<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long n,i,j,k=0,a[100000]={0},sum=0,b[100000],t=0,m,x;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>x;
        a[x]=1;

    }
    for(i=1;;i++)
    {
        if(sum>=m)
            break;
            else
            {
                if(a[i]!=1)
                {
                    sum=sum+i;
                    b[k]=i;
                    k++;
                    t++;
                }
            }
            if(sum>m)
            {
                sum=sum-i;
                k--;
                t--;
                break;
            }

    }
    cout<<t<<endl;
    for(i=0;i<k;i++)
    {
        cout<<b[i]<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k=0,sum=0,t=0,m,x,l;
    vector<long long>s;
    map<long long,long long>mp;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;

    }
    for(i=1;;i++)
    {
        if(sum>=m)
            break;
        if(mp[i]==0)
        {
            sum=sum+i;
            s.push_back(i);
        }
      if(sum>m)
      {
        t=1;

        break;
       }

    }
    if(t==1)
        l=s.size()-1;
    else
        l=s.size();
    cout<<l<<endl;
    for(i=0;i<l;i++)
    {
        cout<<s[i]<<" ";
    }
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long m,a[100000];
int main()
{
    scanf("%d%lld",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    int i;
    for (i=0;i<n;++i)
        if (m+a[i]>(((a[i]+1)*a[i])>>1))
            m+=a[i];
        else
            break;
    int res=0;
    int j=0;
    for (i=1;;++i) {
        if ((((i+1)*i)>>1)>m)
            break;
        if (i!=a[j])
            ++res;
        else
            ++j;
    }
    printf("%d\n",res);
    int k=0;
    for (int j=1;j<i;++j)
        if (k>=n||j!=a[k])
            printf("%d ",j);
        else
            ++k;
    puts("");
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long m,a[100000];
bool vis[200000];
int main()
{
    scanf("%d%lld",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    int i;
    for (i=0;i<n;++i)
        if (m+a[i]>(((a[i]+1)*a[i])>>1))
            m+=a[i];
        else
            break;
    while (i--)
        vis[a[i]]=true;
    int res=0;
    for (i=1;;++i) {
        if ((((i+1)*i)>>1)>m)
            break;
        if (!vis[i])
            ++res;
    }
    printf("%d\n",res);
    for (int j=1;j<i;++j)
        if (!vis[j])
            printf("%d ",j);
    puts("");
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long m,a[100000];
int main()
{
    scanf("%d%lld",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    int i;
    for (i=0;i<n;++i)
        if (m+a[i]>(((a[i]+1)*a[i])>>1))
            m+=a[i];
        else
            break;
    int res=0;
    int j=0;
    for (long long i=1;;++i) {
        if ((((i+1)*i)>>1)>m)
            break;
        if (j>=n||i!=a[j])
            ++res;
        else
            ++j;
    }
    printf("%d\n",res);
    int k=0;
    for (int j=1;j<i;++j)
        if (k>=n||j!=a[k])
            printf("%d ",j);
        else
            ++k;
    puts("");
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long m,a[100000];
bool vis[200000000];
int main()
{
    scanf("%d%lld",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    int i;
    for (i=0;i<n;++i)
        if (m+a[i]>(((a[i]+1)*a[i])>>1))
            m+=a[i];
        else
            break;
    while (i--)
        vis[a[i]]=true;
    int res=0;
    for (i=1;;++i) {
        if ((((i+1)*i)>>1)>m)
            break;
        if (!vis[i])
            ++res;
    }
    printf("%d\n",res);
    for (int j=1;j<i;++j)
        if (!vis[j])
            printf("%d ",j);
    puts("");
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long m,a[100000];
int main()
{
    scanf("%d%lld",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    int i;
    for (i=0;i<n;++i)
        if (m+a[i]>(((a[i]+1)*a[i])>>1))
            m+=a[i];
        else
            break;
    int res=0;
    int j=0;
    for (i=1;;++i) {
        if ((((i+1)*i)>>1)>m)
            break;
        if (i!=a[j])
            ++res;
        else
            ++j;
    }
    printf("%d\n",res);
    int k=0;
    for (int j=1;j<i;++j)
        if (j!=a[k])
            printf("%d ",j);
        else
            ++k;
    puts("");
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
int n;
long long m,a[100000];
int main()
{
    scanf("%d%lld",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    long long i;
    for (i=0;i<n;++i)
        if (m+a[i]>(((a[i]+1)*a[i])>>1))
            m+=a[i];
        else
            break;
    int res=0;
    int j=0;
    for (i=1;;++i) {
        if ((((i+1)*i)>>1)>m)
            break;
        if (j>=n||i!=a[j])
            ++res;
        else
            ++j;
    }
    printf("%d\n",res);
    int k=0;
    for (int j=1;j<i;++j)
        if (k>=n||j!=a[k])
            printf("%d ",j);
        else
            ++k;
    puts("");
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <fstream>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
const int N = 100005;
bool arr[N];
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int v;
		scanf("%d", &v);
		arr[v] = true;
	}
	int base=1;
	bool flag = true;
	vi res;
	while (flag){
		if (!arr[base]){
			if (m - base < 0)
				break;

			res.push_back(base);
			arr[base] = true;
			m -= base;
		}
		base++;
	}
	printf("%d\n", res.size());
	for (vi::iterator i = res.begin(); i != res.end(); i++)
		printf("%d ", *i);

	puts("");
	return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <fstream>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
const int N = 1000000005;
bool arr[N];
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int v;
		scanf("%d", &v);
		arr[v] = true;
	}
	int base=1;

	vi res;
	while (base<=m){
		if (!arr[base]){
			if (m - base < 0)
				break;

			res.push_back(base);
			arr[base] = true;
			m -= base;
		}
		base++;
	}
	printf("%d\n", res.size());
	for (vi::iterator i = res.begin(); i != res.end(); i++)
		printf("%d ", *i);

	puts("");
	return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <fstream>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
vi arr;
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int v;
		scanf("%d", &v);
		arr.push_back(v);
	}
	int base=1;
	sort(arr.begin(), arr.end());
	vi res;
	while (base<=m){
		if (!binary_search(arr.begin(),arr.end(),base)&&!binary_search(res.begin(),res.end(),base)){
			if (m - base < 0)
				break;

			res.push_back(base);

			m -= base;
		}
		base++;
	}
	printf("%d\n", res.size());
	for (vi::iterator i = res.begin(); i != res.end(); i++)
		printf("%d ", *i);

	puts("");
	return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <fstream>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
vi arr;
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int v;
		scanf("%d", &v);
		arr.push_back(v);
	}
	int base=1;
	sort(arr.begin(), arr.end());
	vi res;
	while (base<=m){
		if (!binary_search(arr.begin(),arr.end(),base)&&!binary_search(res.begin(),res.end(),base)){
			if (m - base < 0)
				break;
			arr.push_back(base);

			res.push_back(base);

			m -= base;
		}
		base++;
	}
	printf("%d\n", res.size());
	for (vi::iterator i = res.begin(); i != res.end(); i++)
		printf("%d ", *i);

	puts("");
	return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <fstream>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
vi arr;
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int v;
		scanf("%d", &v);
		arr.push_back(v);
	}
	int base=1;
	sort(arr.begin(), arr.end());
	set<int> res;
	while (base<=m){
		if (!binary_search(arr.begin(),arr.end(),base)&&!binary_search(res.begin(),res.end(),base)){
			if (m - base < 0)
				break;
			arr.push_back(base);

			res.insert(base);

			m -= base;
		}
		base++;
	}
	printf("%d\n", res.size());
	for (set<int>::iterator i = res.begin(); i != res.end(); i++)
		printf("%d ", *i);

	puts("");
	return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <fstream>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
vi arr;
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		int v;
		scanf("%d", &v);
		arr.push_back(v);
	}
	int base=1;

	vi res;
	while (base<=m){
		if (!binary_search(arr.begin(),arr.end(),base)){
			if (m - base < 0)
				break;
			arr.push_back(base);
			res.push_back(base);
			//arr[base] = true;
			m -= base;
		}
		base++;
	}
	printf("%d\n", res.size());
	for (vi::iterator i = res.begin(); i != res.end(); i++)
		printf("%d ", *i);

	puts("");
	return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,i,j,x;
	cin>>n>>m;
	vector<long long> a;
	vector<long long> b;
	vector<long long>::iterator it;
	for(i=0;i<n;i++)
	{
		cin>>x;
		a.push_back(x);
	}
	i=1;
	while(m)
	{
		it=find(a.begin(),a.end(),i);
		if(it==a.end())
		{
			if(m>=i)
			{
			b.push_back(i);
			m=m-i;

			i++;
			}
			else
			{
				break;
			}
		}
		else
		{
			i++;
		}
	}
	cout<<b.size()<<endl;
	i=0;
	while(i<b.size())
	{
		cout<<b[i]<<" ";
		i++;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,i,j,x;
	cin>>n>>m;
	vector<long long> a;
	vector<long long> b;
	vector<long long>::iterator it;
	for(i=0;i<n;i++)
	{
		cin>>x;
		a.push_back(x);
	}
	i=1;
	for(i=1;i<=m;i++)
	{
		it=find(a.begin(),a.end(),i);
		if(it==a.end())
		{
			if(m>=i)
			{
				m=m-i;
				b.push_back(i);
			}
			else
			{
				break;
			}
		}
	}
	cout<<b.size()<<endl;
	i=0;
	while(i<b.size())
	{
		cout<<b[i]<<" ";
		i++;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,i,x;
	long value[1000001]={0};
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>x;
		value[x]=1;
	}
	vector<long long> b;
	i=1;
	while(m)
	{
		if(value[i]==0)
		{
			if(m>=i)
			{
				m=m-i;
				b.push_back(i);

			}
			else
			{
				break;
			}
		}
		i++;
	}
	i=0;
	cout<<b.size()<<endl;
	while(i<b.size())
	{
		cout<<b[i]<<" ";
		i++;
	}
}


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

int main()
{
	long long n,m,i,x;
	long long* arr;
	cin>>n>>m;
	arr=new long[m+1];
	for(i=0;i<n;i++)
	{
		cin>>x;
		value[x]=1;
	}
	vector<long long> b;
	i=1;
	while(m)
	{
		if(value[i]==0)
		{
			if(m>=i)
			{
				m=m-i;
				b.push_back(i);

			}
			else
			{
				break;
			}
		}
		i++;
	}
	i=0;
	cout<<b.size()<<endl;
	while(i<b.size())
	{
		cout<<b[i]<<" ";
		i++;
	}
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,m,i,j,k,x;
	set<ll> st;
	vector<ll> v;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>x;
		st.insert(x);
	}
	i=1;
	while(i<=m)
	{
		if(st.count(i)==0)
		{
			st.insert(i);
			v.push_back(i);
			m=m-i;
		}
		i++;
	}
	cout<<v.size()<<"\n";
	for(i=0;i<v.size();i++)
	{
		cout<<v[i]<<" ";
	}
}