#include

using namespace std;

int main()

{

long long T,p;

long long k,A,B;

long long i;

float theta;

cin>>T;

```
for(i=1;i<=T;i++)
{
cin>>k>>A>>B;
if(B-A>0)
p=B-A;
else
p=k-B+A;
if(A!=B&&A<=k&&B<=k&&k>=1)
{
theta=p*360/k;
if(theta<180)
cout<<(p-1)<<endl;
else if(theta>=180)
cout<<"0\n";
}
else
cout<<"0\n";
}
return 0;
```

}