#include <stdio.h>
#include <stdlib.h>

	int number,queue,queueparam,num1,num2;
	int *numberset;
	int i,j;

int query(int numberset[],int queueparam,int num1,int num2){}

int problem1508(){
	scanf("%d %d",number,queue);
	numberset=(int *)malloc(sizeof(int)*number);
	for(i=0;i<number;i++){
	scanf("%d",numberset[i]);
	}
	for(i=0;i<queue;i++){
	scanf("%d %d %d",queueparam,num1,num2);
	query(numberset,queueparam,num1,num2);
	}
	free(numberset);
	return 0;
}

int query(int numberset[],int queueparam,int num1,int num2){
	int temp;
	int min_number;
	for(i=0;i<queue;i++){
		temp=0; min_number=0;
		switch(queueparam){
		case 0:
			temp=numberset[num2];
		for(j=num1;j<num2;j++){
			numberset[j+1]=numberset[j];
		}
			numberset[num1]=temp;
		break;
		case 1:
		min_number=numberset[num1];
		for(j=num1;j<num2;j++){
			if(min_number>numberset[j]){min_number=numberset[j];}
		}
		printf("%d\n",min_number);
		break;
		case 2:
		temp=numberset[num1];
		numberset[num1]=numberset[num2];
		numberset[num2]=temp;
		break;
		}
	}
}