permut2 solution is wrong ..how

#include<bits/stdc++.h>
using namespace std;

int main()
{
int n,x,u,arr[10],t;
cin>>t;
while(t–)
{

cin>>n;
if(n!=0)
{

for(x=1;x<=n;x++)
{
	cin>>u;
	arr[x]=u;
}
int i,s;
for(x=1;x<=n;x++)
{
	if(arr[arr[x]]==x)
	{
		s=x;
	continue;
	}
	else
	{
	s=x;
	break;}
	}
if(s!=n)
{cout<<"not ambiguous";
}
else
{cout<<"ambiguous";
}

}

}
}