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.*;

public class CF102 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      int q=sc.nextInt();
      for(int i=0;i<q;i++){
          int n=sc.nextInt();
          List<Integer> list=new ArrayList<>();

          for(int j=0;j<n;j++){
              list.add(sc.nextInt());
          }
          int index_1=list.indexOf(1);
          boolean checkcase1=true;
          for(int j=0;j<=index_1;j++){
              if(list.get(j)!=(index_1+1-j)){
                  checkcase1=false;
                  break;
              }
          }
          int num=n;
          for (int j=index_1+1;j<n;j++){
              if(list.get(j)!=num){
                  checkcase1=false;
                  break;
              }else {
                  num-=1;
              }
          }
          boolean checkcase2=true;
          int num1=1;
          for(int j=index_1;j<n;j++){
              if(list.get(j)!=num1){
                  checkcase2=false;
                  break;
              }else {
                  num1+=1;
              }
          }
         // int num=n;
          for (int j=0;j<index_1;j++){
              if(list.get(j)!=num1){
                  checkcase2=false;
                  break;
              }else {
                  num1+=1;
              }
          }

          if(checkcase1||checkcase2){
              System.out.println("YES");
          }else {
              System.out.println("NO");
          }

      }




    }


    public static int getAns(char[] s1, int i, int j, int[][] dp) {

        if (i > j) {
            return 0;
        }
        if (dp[i][j] != -1) {

            return dp[i][j];

        }
        if (s1[i] == s1[j]) {
            dp[i][j] = getAns(s1, i + 1, j - 1, dp);
        } else {
            int ans1 = getAns(s1, i + 1, j, dp);
            int ans2 = getAns(s1, i, j - 1, dp);
            dp[i][j] = 1 + Math.min(ans1, ans2);
        }

        return dp[i][j];


    }

    public static boolean funky(long mid, long n, long orig) {
        long vas = 0;
        while (n > 0) {
            long y = Math.min(mid, n);
            n -= y;
            vas = vas + y;
            n -= n / 10;
        }
        return 2 * vas >= orig;
    }


    public static long sweetness(long a) {
        long c = 0;
        for (long i = 1; i <= a; i++) {
            if (gcd(i, a) == 1) {
                c++;
            }
        }
        return c;
    }

    public static long power(long a, long b, long c) {
        long ans = 1;
        while (b != 0) {
            if (b % 2 == 1) {
                ans = ans * a;
                ans %= c;
            }
            a = a * a;
            a %= c;
            b /= 2;
        }
        return ans;
    }

    public static long power1(long a, long b, long c) {
        long ans = 1;
        while (b != 0) {
            if (b % 2 == 1) {
                ans = multiply(ans, a, c);
            }
            a = multiply(a, a, c);
            b /= 2;

        }
        return ans;

    }

    public static long multiply(long a, long b, long c) {
        long res = 0;
        a %= c;
        while (b > 0) {
            if (b % 2 == 1) {
                res = (res + a) % c;
            }
            a = (a + a) % c;
            b /= 2;
        }

        return res % c;

    }

    public static long totient(long n) {
        long result = n;
        for (long i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                //sum=sum+2*i;
                while (n % i == 0) {
                    n /= i;
                    // sum=sum+n;
                }
                result -= result / i;

            }
        }
        if (n > 1) {
            result -= result / n;

        }
        return result;
    }


    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static boolean[] primes(int n) {
        boolean[] p = new boolean[n + 1];
        p[0] = false;
        p[1] = false;
        for (int i = 2; i <= n; i++) {
            p[i] = true;
        }

        for (int i = 2; i * i <= n; i++) {
            if (p[i]) {
                for (int j = i * i; j <= n; j += i) {
                    p[j] = false;
                }
            }

        }
        return p;
    }

    public int minimumLength(String s) {
        String s1 = "";
        for (int i = 0; i < s.length() - 1; i++) {
            char ch = s.charAt(i);
            char ch1 = s.charAt(i + 1);
            if (ch != ch1) {
                s1 = s1 + ch;

            }


        }
        s1 = s1 + s.charAt(s.length() - 1);
        String[] ar = s1.split("");
        for (int i = 0; i < s1.length() - 1; i++) {
            if (i <= s1.length() - 1 - i) {
                char ch1 = ar[i].charAt(0);
                char ch2 = ar[s1.length() - 1 - i].charAt(0);
                if (ch1 != ch2) {
                    break;
                } else {
                    ar[i] = "";
                    ar[s1.length() - 1 - i] = "";
                }
            } else {
                break;
            }

        }

        String s2 = "";
        for (String s3 : ar) {
            s2 = s2 + s3;
        }

        return s2.length();


    }

    public static long[] totientfrom1ton(long n) {
        long[] totient = new long[(int) (n + 1)];
        totient[0] = 0;
        totient[1] = 1;
        for (int i = 2; i <= n; i++) {
            totient[i] = i;
        }
        for (int i = 2; i <= n; i++) {
            if (totient[i] == i) {
                totient[i] -= 1;
                for (int j = 2 * i; j <= n; j += i) {
                    totient[j] -= totient[j] / i;
                }
            }
        }
        return totient;

    }

    static long[] LcmSum(int n, long[] phi) {
        //ETF();
        long[] ans = new long[n + 1];

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

            // Summation of d * ETF(d) where
            // d belongs to set of divisors of n
            for (int j = i; j <= n; j += i) {
                ans[j] += (i * phi[i]);
            }
        }

        for (int i = 1; i <= n; i++) {
            ans[i] = ((ans[i] + 1) * i) / 2;
        }

        /*int answer = ans[m];
        answer = (answer + 1) * m;
        answer = answer / 2;*/
        return ans;
    }

    static int hackerlandRadioTransmitters(int[] x, int k) {
        Arrays.sort(x);
        int c = 0;
        int lol = 0;
        process:
        while (lol <= (x.length - 1)) {


            int initial = x[lol];
            int nextno = initial + 2 * k;
            int low = lol + 1;
            int high = x.length - 1;
            int ans = -1;
            while (low <= high) {
                int mid = low + (high - low) / 2;
                if (x[mid] <= nextno) {
                    ans = mid;
                    low = mid + 1;
                } else {
                    high = mid - 1;
                }
            }
            if (ans != -1) {
                c++;
            }
            System.out.println(ans + " " + lol);
            lol = ans + 1;
        }
        return c;


    }
}