#include #include using namespace std; bool flag[30]; int T,n,cnt; long long a[30],p[30],q[30]; int nxt(int x){ x=x % n + 1; while(!flag[x]){ x=x % n + 1; } return x; } long long gcd(long long x,long long y){ if (x==0) return y; return gcd(y % x,x); } int x; int main(){ #ifdef YJQ_LOCAL freopen(".in","r",stdin); #endif scanf("%d",&T); while(T--){ scanf("%d",&n); for (int i=1;i<=n;i++){ scanf("%d",&x); a[x]=i; } for (int i=1;i<=n;i++){ if (i=1;i--){ if (i!=n) cur=nxt(cur); cnt=0; while(cur!=a[i]){ cur=nxt(cur); cnt++; } cnt++; q[i]=cnt % i; p[i]=i; flag[a[i]]=false; } for (int i=n;i>1;i--){ long long tmp=p[i]*p[i-1]/gcd(p[i],p[i-1]); while(q[i] % p[i-1]!=q[i-1] && q[i]<=tmp) q[i]+=p[i]; if (q[i] % p[i-1]!=q[i-1]){ printf("Creation August is a SB!\n"); flag[0]=1; break; } q[i-1]=q[i]; p[i-1]=p[i]*p[i-1]/gcd(p[i],p[i-1]); } if (q[1]==0) q[1]=p[1]; if (!flag[0]) printf("%I64d\n",q[1]); } }