Why is this answer not correct !? COVID RUN Problem 1 Div 2

What is wrong with my code ?
https://www.codechef.com/viewsolution/38749965

Also if you are too tired to click on the link… Here’s the code.

#include
using namespace std;
int main()
{
int testcase;
cin>>testcase;
int n;
int x,y;
int k;
int temp;
for(int t=0;t!=testcase;t++)
{
cin>>n;
cin>>x>>y>>k;
k = k%n; //making k less than n though it doesn’t matter
temp = x;
bool flagnord = false;
if(n==1)
cout<<“YES”<<endl;
else if(x==y)
cout<<“YES”<<endl;
else if(k==0)
cout<<“NO”<<endl;
else if(n%k!=0)
cout<<“YES”<<endl;
else
{
temp = (temp+k)%n; //temp = x (in this step)
while(temp != x)
{
if(temp==y)
{
flagnord = true;
break;
}
temp = (temp+k)%n;
}

        if(flagnord==true)
             cout<<"YES"<<endl;
        else
             cout<<"NO"<<endl;
    }
}
return 0;

}