I cannot figure out the error in my code, which is as follows:
/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int t=Integer.parseInt(br.readLine());
if(t<=10 && t>=0)
{
for(int k=0;k<t;k++)
{
String x1=br.readLine();
String x2=br.readLine();
int l=Integer.parseInt(br.readLine());
String x3=br.readLine();
x1=x1.trim();
int a=x1.indexOf(' ');
String M=x1.substring(0,a);
long m=Long.parseLong(M);
String N=x1.substring(a+1);
long n=Long.parseLong(N);
x2=x2.trim();
a=x2.indexOf(' ');
String R1=x2.substring(0,a);
long rx=Long.parseLong(R1);
String R2=x2.substring(a+1);
long ry=Long.parseLong(R2);
if(rx>m || ry>n || m<0 || m>10000 || n<0 || n>10000 || l>10000 || l<0 || rx<0 || ry<0)
{
System.out.println("Case "+(k+1)+":");
}
long x=0;
long y=0;
for(int i=0;i<l;i++)
{
char z=x3.charAt(i);
if(z=='R')
x=x+1;
else if(z=='L')
x=x-1;
else if(z=='U')
y=y+1;
else if(z=='D')
y=y-1;
else
{ System.out.println("Incorrect sequence");
break;
}
}
//System.out.println("x:"+x);
//System.out.println("y:"+y);
if((x>m || x<0) || (y<0 || y>n))
System.out.println("Case "+(k+1)+": Danger");
else
{
if(x==rx && y==ry)
System.out.println("Case "+(k+1)+": Reached");
else
System.out.println("Case "+(k+1)+": Somewhere");
}
}
}
}
}
}