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.io.*;
import java.util.*;

import javax.swing.plaf.synth.SynthSeparatorUI;
public class Problem3 {
	static Scanner sc=new Scanner(System.in);
	static PrintWriter out=new PrintWriter(System.out);
	public static void main(String[] args) throws IOException, InterruptedException {
		int q=sc.nextInt();
		while(q-->0) {
			int n=sc.nextInt();
			int a[]=new int[n];
			int b[]=new int[2*n];
			
			for (int i = 0; i < a.length; i++) {
				a[i]=sc.nextInt();
				b[i]=a[i];
			}
			for (int i = n; i < b.length; i++) {
				b[i]=a[i-n];
			}
			boolean f1=true;
			boolean f2=true;
		for (int i = 0; i < a.length; i++) {
			f1=true;
			for (int j = i; j < i+n-1; j++) {
			if(b[j]>b[j+1]) {
				f1=false;
				break;
			}
			}
			if(f1) {
				break;
			}
		}
		for (int i = 0; i < a.length; i++) {
			f2=true;
			for (int j = i; j < i+n-1; j++) {
			if(b[j]<b[j+1]) {
				f2=false;
				break;
			}
			}
			if(f2) {
				break;
			}
		}
		if(f1|f2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		
		
		
		}
	}
static int 	factprime(int n,int p) {
	int pow=0;
	for(int i=p ; i<=n ; i=i*p) {
		pow+=n/i;
	}
	return pow;
}
static long power(long x, long y) 
{ 
    long temp; 
    if( y == 0) 
        return 1; 
       
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return ((temp%10)*(temp)%10)%10; 
    else
        return ((x%10)*(temp%10)*(temp%10))%10;
}  
	static ArrayList<Integer> adj[];
static Stack<Integer> st=new Stack<>();
static  boolean visited[];
static void dfs(int i){
	visited[i]=true;
	st.add(i);
	for(int x:adj[i]) {
		if(!visited[x])
			dfs(x);
	}
}


	static  class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s) {
		br = new BufferedReader(new InputStreamReader(s));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public int[] nextIntArr(int n) throws IOException {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = nextInt();
		return arr;
	}

	public long[] nextLongArr(int n) throws IOException {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = nextLong();
		return arr;
	}

	public long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public boolean ready() throws IOException {
		return br.ready();
	}
	public void waitForInput() throws InterruptedException {Thread.sleep(2300);}
}



static class SegmentTree {
	int N; // number of elements in my array after the padding
	int [] array, sTree, lazy; 
	SegmentTree(int []inp){
		N = inp.length - 1;
		array = inp;
		sTree =  new int[N<<1];
		lazy =  new int[N<<1];
		build(1, 1, N);
	}
	void build(int node, int b, int e) {
		if(b == e) {
			//node = b + N - 1
			// update(idx , value)
			// sTree[idx + N - 1] += value
			sTree[node] = array[b];
		}
		else {
			int nodeLeft = node << 1;
			int nodeRight = (node << 1)+1;
			int mid = (b + e) >> 1;
			build(nodeLeft, b , mid);
			build(nodeRight, mid + 1, e);
			sTree[node] = sTree[nodeLeft] + sTree[nodeRight];
		}
	}
	void propagate(int node, int b, int e) {
		int leftChild = node << 1;
		int rightChild = node<<1|1;
		lazy[leftChild] += lazy[node];
		lazy[rightChild] += lazy[node];
		int mid = (b + e)>>1;
		if(lazy[node]%2!=0) {
		sTree[leftChild] = (mid - b + 1)-sTree[leftChild];
		sTree[rightChild] =(e - mid)-sTree[rightChild];
		}
		lazy[node] = 0;
	}
	// add value v for element in position idx in my input array
	//O(log(N))
	void update_point(int idx, int v) {
		int node = idx + N - 1;
		sTree[node] += v;
		while(node > 1) {
			node >>= 1;
			sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
		}
	}
	// O(log(N))
	int query(int i, int j) {
		return query(1, 1, N, i, j); 
	}
	int query(int node, int b, int e, int i, int j) {
		
		
		if(i > e || j < b)
			return 0;
		if(b >= i && e <= j)
			return sTree[node];
		int mid = (b + e) >> 1;
		propagate(node, b, e);
        int q1 = query(node << 1, b, mid, i , j);
		int q2 = query(node<<1|1, mid + 1, e, i, j);
		return q1 + q2;
		
		
	}
	void update_range(int i, int j) { //O(log(N))
		update_range(1, 1, N, i, j); 
	}
	void update_range(int node, int b, int e, int i, int j) {
		if(i > e || j < b)
			return;
		if(b >= i && e <= j) {
			sTree[node] = (e - b + 1)-sTree[node];
			lazy[node]+=1;
		}
		else {
			int mid = (b + e) >> 1;
			propagate(node, b, e);
			update_range(node<<1, b , mid, i, j);
			update_range(node<<1|1, mid+1, e, i, j);
			sTree[node] = sTree[node<<1] + sTree[node<<1|1];
		}
	}
}
}

	

