Magician versus Chef Problem Code: MAGICHF

magician versus Chef Problem Code: MAGICHF
I am getting write answer but chef says it’s wrong why?
My code
#include

using namespace std;

int main()
{
int t,s,a,i,b,n,x,ar[100000];
cin>>t;
while(t–)
{
cin>>n>>x>>s;

for(i=1;i<=n;i++)
ar[i]=-1;
ar[x]=0;
while(s–)
{
cin>>a>>b;
int t;
t=ar[a];
ar[a]=ar[b];
ar[b]=t;
}

for(i=1;i<n;i++)
if(ar[i]==0)
{cout<<i;
break;
}
}
return 0;
}

//