There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).

Students want to start a round dance. A clockwise round dance can be started if the student 2 comes right after the student 1 in clockwise order (there are no students between them), the student 3 comes right after the student 2 in clockwise order, and so on, and the student n comes right after the student n - 1 in clockwise order. A counterclockwise round dance is almost the same thing — the only difference is that the student i should be right after the student i - 1 in counterclockwise order (this condition should be met for every i from 2 to n). 

For example, if the indices of students listed in clockwise order are [2, 3, 4, 5, 1], then they can start a clockwise round dance. If the students have indices [3, 2, 1, 4] in clockwise order, then they can start a counterclockwise round dance.

Your task is to determine whether it is possible to start a round dance. Note that the students cannot change their positions before starting the dance; they cannot swap or leave the circle, and no other student can enter the circle. 

You have to answer q independent queries.

Input

The first line of the input contains one integer q (1 ≤ q ≤ 200) — the number of queries. Then q queries follow.

The first line of the query contains one integer n (1 ≤ n ≤ 200) — the number of students.

The second line of the query contains a permutation of indices p_1, p_2, ..., p_n (1 ≤ p_i ≤ n), where p_i is the index of the i-th student (in clockwise order). It is guaranteed that all p_i are distinct integers from 1 to n (i. e. they form a permutation).

Output

For each query, print the answer on it. If a round dance can be started with the given order of students, print "YES". Otherwise print "NO".

Example

Input


5
4
1 2 3 4
3
1 3 2
5
1 2 3 5 4
1
1
5
3 2 1 5 4


Output


YES
YES
NO
YES
YES
import java.util.*;
import java.io.*;
public class div481{
	static int mod = (int)1e9+7;
	public static void main(String sp[])throws IOException{
		//Reader sc = new Reader();
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		while(q-->0){
			int n = sc.nextInt();
			ArrayList<Integer> al = new ArrayList<>();
			for(int i=0;i<n;i++)
				al.add(sc.nextInt());
			int start=0;
			for(int i=0;i<n;i++){
				if(al.get(i)==1){
					start=i;
					break;
				}
			}
			ArrayList<Integer> pehla  = new ArrayList<>();
			ArrayList<Integer> dusra  = new ArrayList<>();
			for(int i=start;i<n;i++){
				pehla.add(al.get(i));
			}
			for(int i=0;i<start;i++)
				pehla.add(al.get(i));
			
			
			for(int i=start;i>=0;i--){
				dusra.add(al.get(i));
			}
			
			for(int i=n-1;i>start;i--){
				dusra.add(al.get(i));
			}
			boolean b1=true;
			boolean b2=true;
			for(int i=0;i<pehla.size()-1;i++){
				if(pehla.get(i)>pehla.get(i+1))
					b1=false;
			}
			for(int i=0;i<dusra.size()-1;i++){
				if(dusra.get(i)>dusra.get(i+1))
					b2=false;
			}
			
			if(b1==true || b2==true)
				System.out.println("YES");
			else System.out.println("NO");
			
			
		}
		
		
	}
	
	public static void sudoko(int arr[][], int n, int row, int col){
		
		
		for(int i=row;i<=9;i++){
			for(int j=col;j<=9;j++){
				if(arr[i][j]==0){
					for(int k=1;k<=9;k++){
						if(check1(arr, i, j, n, k)==true && check2(arr, i, j, n, k)==true){
							System.out.println(i+" "+j+" "+k);
							arr[i][j]=k;
							sudoko(arr, n, i, j);
							arr[i][j]=0;
						}
					}					
				}
			}
		}
		
	}
	
	//checkig the 3*3 pair
	public static boolean check1(int arr[][], int i, int j, int n, int k){
		HashMap<Integer,Integer> hm = new HashMap<>();
		int y=i;
		int z=j;
		int mod1 = i/3;
		int mod2 = j/3;
		if(i%3!=0)
			i=1;
		
		if(j%3!=0)
			j=1;
		System.out.println(i+" "+j);
	    i += (mod1*3);
		j += (mod2*3);
		
		//System.out.println(i+" "+j);
		for(int l=i;l<=i+3;l++){
			for(int r=j;r<=j+3;j++){
				hm.put(arr[l][r],0);
			}
		}
		
		if(hm.containsKey(k)){
			return false;
		}
		return true;
	}
	
	//checking diagonal both, row and col
	public static boolean check2(int arr[][], int i, int j, int n, int k){
		HashMap<Integer,Integer> hm = new HashMap<>();
		for(int l=1;l<=9;l++){
			hm.put(arr[i][l],0);
		}
		
		for(int l=1;l<=9;l++){
			hm.put(arr[l][j],0);
		}
		
		if(hm.containsKey(k))
			return false;
		
		return true;
	}
	
	
	
	public static int[] quick(int[] arr, int s, int e){
		
		if(s>=e)
			return arr;
		
		int y = partition(arr, s, e);
		int[] l = quick(arr, s, y-1);
		int[] r = quick(arr, y+1, e);
		
		return arr;
		
	}
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	public static class pair{
		int ai;
		int bi;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return o1.bi-o2.bi;
		}
	}

	static class Reader
		{
			final private int BUFFER_SIZE = 1 << 16;
			private DataInputStream din;
			private byte[] buffer;
			private int bufferPointer, bytesRead;
			BufferedReader br;
			public Reader()
			{
				din = new DataInputStream(System.in);
				buffer = new byte[BUFFER_SIZE];
				bufferPointer = bytesRead = 0;
				br = new BufferedReader(new InputStreamReader(System.in));
			}
	 
			public Reader(String file_name) throws IOException
			{
				din = new DataInputStream(new FileInputStream(file_name));
				buffer = new byte[BUFFER_SIZE];
				bufferPointer = bytesRead = 0;
			}
	 
			public String readLine() throws IOException
			{
				byte[] buf = new byte[64]; // line length
				int cnt = 0, c;
				while ((c = read()) != -1)
				{
					if (c == '\n')
						break;
					buf[cnt++] = (byte) c;
				}
				return new String(buf, 0, cnt);
			}
			
			
			
	 
			public int nextInt() throws IOException
			{
				int ret = 0;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do
				{
					ret = ret * 10 + c - '0';
				} while ((c = read()) >= '0' && c <= '9');
	 
				if (neg)
					return -ret;
				return ret;
			}
	 
			public long nextLong() throws IOException
			{
				long ret = 0;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do
				{
					ret = ret * 10 + c - '0';
				}
				while ((c = read()) >= '0' && c <= '9');
				if (neg)
					return -ret;
				return ret;
			}
	 
			public double nextDouble() throws IOException
			{
				double ret = 0, div = 1;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
	 
				do
				{
					ret = ret * 10 + c - '0';
				}
				while ((c = read()) >= '0' && c <= '9');
	 
				if (c == '.')
				{
					while ((c = read()) >= '0' && c <= '9')
					{
						ret += (c - '0') / (div *= 10);
					}
				}
	 
				if (neg)
					return -ret;
				return ret;
			}
	 
			private void fillBuffer() throws IOException
			{
				bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
				if (bytesRead == -1)
					buffer[0] = -1;
			}
	 
			private byte read() throws IOException
			{
				if (bufferPointer == bytesRead)
					fillBuffer();
				return buffer[bufferPointer++];
			}
			StringTokenizer st;
			String next() {
				while (st == null || !st.hasMoreTokens()) {
					try {
						st = new StringTokenizer(br.readLine());
					} catch (Exception r) {
						r.printStackTrace();
					}
				}
				return st.nextToken();
			}
	 
	 
			public void close() throws IOException
			{
				if (din == null)
					return;
				din.close();
			}
		}
}