public static void findWay(int[][] maze, Pair start, Pair end) {
        LinkedList<Pair> queue = new LinkedList<>();
        Map<Pair, Pair> parent = new HashMap<>();


        queue.addLast(start);
        parent.put(start, null);

        while(!queue.isEmpty()) {
            Pair p = queue.removeFirst();
            if(p.equals(end)) {
                break;
            }

            // find all the neighbours who are are not walls or previously visited
            for(Pair neighbour : getAllNeighbour(p, maze)) {
                if(!parent.containsKey(neighbour)){
                    queue.addLast(neighbour);
                    parent.put(neighbour, p);
                }
            }
        }

        //follow the parent pointer
        if(parent.containsKey(end)) {
            maze[end.x][end.y] = 3;
            while(true) {
                if(parent.get(end) == null) {
                    break;
                }
                maze[parent.get(end).x][parent.get(end).y] = 3;
                end = parent.get(end);
            }
        }
        printBoard(maze);
    }