For this Question: Given a boolean 2D matrix (0-based index), find whether there is path from (0,0) to (x,y) and if there is one path, print the minimum no of steps needed to reach it, else print -1 if the destination is not reachable. You may move in only four direction ie up, down, left and right. The path can only be created out of a cell if its value is 1. The first line  contains two integers n and m denoting the size of the matrix. Then in the next line are n*m space-separated values of the matrix. The following line after it contains two integers x and y denoting the index of the destination.

Constraints:
1<=n,m<=1000For each test case print in a new line the min no of steps needed to reach the destination.Input:
3 4
1 0 0 0 1 1 0 1 0 1 1 1
2 3

Output
5

Input
3 4
1 1 1 1 0 0 0 1 0 0 0 1
0 3

Output:
3, I have written this Solution Code: import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.io.*;
import java.util.*;


class Main {
	private static Reader fr;
	private static OutputStream out;
	private static final int delta = (int) 1e9 + 7;

	private static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[1024];
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}

    }
	public static void main(String args[]) throws IOException {
		run();
	}

	private static void run() throws IOException {
		fr = new Reader();
		out = new BufferedOutputStream(System.out);
		solve();
		out.flush();
		out.close();
	}
	static int mod=1000000007;
    static int dx=0,dy=0;
    static int a=0;
    static int minn=Integer.MAX_VALUE;
	private static void solve() throws IOException
	{

        int n=fr.nextInt();
        int m=fr.nextInt();

        int arr[][]= new int[n][m];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                arr[i][j]=fr.nextInt();
            }
        }
        dx=fr.nextInt();
        dy=fr.nextInt();
        int ans=bfs(arr);
        System.out.println(ans);
    }


    static class Node{
        int x,y;
        Node(int x,int y){
            this.x=x;
            this.y=y;
        }
    }

    static int bfs(int arr[][]){
        int n=arr.length;
        int m=arr[0].length;
        Queue<Node> q=new LinkedList<>();
        q.add(new Node(0,0));

        if(arr[0][0]==0) return -1;
        arr[0][0]=0;
        int count=0;
        while(!q.isEmpty()){
            int size=q.size();
            for(int i=0;i<size;i++){

                Node temp=q.poll();
                if(temp.x==dx && temp.y==dy){
                    return count;
                }else{

                    if((temp.x-1 >= 0 && temp.x-1 < n) && arr[temp.x-1][temp.y] == 1) {
                        arr[temp.x-1][temp.y]=0;
			            q.add(new Node(temp.x-1, temp.y));
                        a++;
		            }
		            if((temp.x+1 >= 0 && temp.x+1 < n) && arr[temp.x+1][temp.y] == 1) {
                        arr[temp.x+1][temp.y]=0;
		    	        q.add(new Node(temp.x+1, temp.y));
                        a++;
		            }
		            if((temp.y-1 >= 0 && temp.y-1 < m) && arr[temp.x][temp.y-1] == 1) {
                        arr[temp.x][temp.y-1]=0;
		    	        q.add(new Node(temp.x, temp.y-1));
                        a++;
		            }
		            if((temp.y+1 >= 0 && temp.y+1 < m) && arr[temp.x][temp.y+1] == 1) {
                        arr[temp.x][temp.y+1]=0;
		    	        q.add(new Node(temp.x, temp.y+1));
                        a++;
		            }
                }
            }
            count++;
        }
        return -1;
    }

}, In this Programming Language: Java, Now tell me if this Code is compilable or not?