problem code : CENS20G
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–)
{
string s;
cin>>s;
long x1,x2,y1,y2,d1,d2,c=0,cx1,cy1;
cin>>cx1>>cy1;
int q;
cin>>q;
while(q--)
{
x1=cx1;
y1=cy1;
cin>>x2>>y2;
for(int i=0;i<s.length();i++)
{
if(x1<x2&&s[i]=='R')
{
x1++;
c++;
}
if(x1>x2&&s[i]=='L')
{
x1--;
c++;
}
if(y1<y2&&s[i]=='U')
{
y1++;
c++;
}
if(y1>y2&&s[i]=='D')
{
y1--;
c++;
}
}
if(x1==x2&&y1==y2)
cout<<"YES "<<c;
else
cout<<"NO";
cout<<endl;
}
}
return 0;
}