why my code is wrong?

I’m trying to solve the problem http://poj.org/problem?id=3009, but I have as a result Wrong Answer.
I try all the test cases and others and all were ok.
If someone find the mistakes in the code or a case that returns a mistake it would be great.

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Nodo{
public int x;
public int y;
public int disActual;
public Nodo(int x1,int y1,int d){
x=x1;
y=y1;
disActual=d;
}

}

public class P3009 {

private static int[][] mat= new int[20][20];

public static void main (String []args){
	Scanner in = new Scanner(System.in);
	int w=in.nextInt();
	int h=in.nextInt();
	
	while(w!=0){
		int xO=0;
		int yO=0;
		
		int xD=0;
		int yD=0;
		for(int i = 0;i<w;i++){
			for(int j=0;j<h;j++){
				mat[i][j]=in.nextInt();
				if(mat[i][j]==2){
					xO=i;yO=j;
				}else if(mat[i][j]==3){
					xD=i;yD=j;
				}
			}
		}
		int min=bfs(mat,xO,yO,xD,yD,w,h);
		System.out.println(min);
		
		

		w=in.nextInt();
		h=in.nextInt();
	}
	
	
}

private static int bfs(int[][] mat2, int xO, int yO, int xD, int yD,int w,int h) {
Queue<Nodo> cola = new LinkedList<Nodo>();	
Nodo origen = new Nodo(xO,yO,0);
cola.add(origen);
int dis=0;
while(!cola.isEmpty()&&dis<=10){

		Nodo aux2=cola.remove();
		if(aux2.x==xD&&aux2.y==yD){
			return aux2.disActual;
		}
		
		int[][]mov={{1,0},{-1,0},{0,1},{0,-1}};
		for(int i=0; i<4; i++){
				Nodo aux=new Nodo(aux2.x,aux2.y,aux2.disActual);
				
				int pasos=0;
				while(estaEnMatriz(aux.x, aux.y, w, h)&&mat[aux.x][aux.y]!=1&&mat[aux.x][aux.y]!=3){
					aux.x+=mov[i][0];
					aux.y+=mov[i][1];
					pasos++;
				}
				if(estaEnMatriz(aux.x, aux.y, w, h)&&(pasos>1||mat[aux.x][aux.y]==3)){
					if(mat[aux.x][aux.y]==1){
						mat[aux.x][aux.y]=0;
						aux.x-=mov[i][0];
						aux.y-=mov[i][1];
					}
					aux.disActual++;
					cola.add(aux);
				}
		}
		dis++;			
	}
	return -1;
}

public static boolean estaEnMatriz(int x,int y, int w, int h){
	return x>=0&&y>=0&&x<w&&y<h;
	
}

}

//