public static int shortestDistance(boolean[][]b, int i, int j, int y, int x) {
		if (i==y&&j==x)
			return 0;
		Queue<Integer>q=new ArrayDeque<>();
		int m=b.length, n=b[0].length;
		boolean[][]v=new boolean[m][n];
		int dist=0;
		q.offer(i*n+j);
		v[i][j]=true;
		List<Orientation> dir=new ArrayList<>(Arrays.asList(Orientation.N,Orientation.E,Orientation.S,Orientation.W));
		while (!q.isEmpty()) {
			++dist;
			for (int k=0, s=q.size();k<s;++k) {
				i=q.peek()/n;
				j=q.poll()%n;
				for (Orientation e:dir) {
					int[] next=nextHelper(b, i, j, e);
					int y1=next[0], x1=next[1];
					if (!v[y1][x1]) {
						if (onHelper(y1, x1, i, j, y, x))
							return dist;
						v[y1][x1]=true;
						q.offer(y1*n+x1);
					}
				}
			}
		}
		return -1;
	}