Riezo or Not

1

1 votes
Problem

Your senior is planning to give you Fresher's party only if you perform the following task .

He has an identity permutation array . An identity permutation in an array where each element Ai=i . Identity permutation of length 4 is [1,2,3,4]. 5665  5665

Now President had an identity permuation of length N .

  • He rotated it to left by some steps possible 0 or more
  • and then rotated it to  right by some steps possibly 0 or more . 

Rotation of  above permutation  in left by one step  gives [2,3,4,1]  and after rotation to right by one step gives  [4,1,2,3] . 

You are given the final state of array after both above rotations you need to tell wheather President started with identity permutation or not . If Yes then he promises you to give Fresher's Party so print "Riezo" , else he will not give you fresher's party so print "No Riezo" . 

Constraints :

  • 1<=t<=104
  • 1<=N<=106
  • 1<=Ai<=N
  • All Ai are distinct.
  • sum of N over all test cases doesn't exceed 106 

Input Format :

First line contains an integer T representing number of testcases.

For each testcase, first line contains an integer N, the size of Array .

Next line of each testcase contains N space separated integers A1,A2,A3,....An

Output Format :

For each testcase, Print the "Riezo" for Yes and print "No Riezo" for No .

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

In first test case if you rotate [1,2,3,4,5]  by 1 on left you get [2,3,4,5,1]  and after rotating it again to right by 3 you get [4,5,1,2,3]. so there are valid operations which transform identity permutation to given array .

In second test case there are no such operations from identity permutation to get this array .

In third test case you don't need to perform any operation . 

Editor Image

?