private static void bfsSearch() {
        boolean[][] used = new boolean[H + 2][W + 2];
        Deque<Integer> xQue = new ArrayDeque<Integer>();
        Deque<Integer> yQue = new ArrayDeque<Integer>();

        xQue.add(1);
        yQue.add(1);

        Deque<Integer> nextXQue = new ArrayDeque<Integer>();
        Deque<Integer> nextYQue = new ArrayDeque<Integer>();
        boolean isPossible = false;
        int index = 0;
        for (; index < H * W; index++) {
            while(!xQue.isEmpty()) {
                int x = xQue.poll();
                int y = yQue.poll();
                if (x == H && y == W) {
                    isPossible = true;
                    System.out.println(index);
                    break;
                }
                for (int i = 0; i < 4; i++) {
                    int mx = x + dx[i];
                    int my = y + dy[i];
                    if (field[my][mx] == '.' && !used[my][mx]) {
                        used[my][mx] = true;
                        nextXQue.add(mx);
                        nextYQue.add(my);
                    }
                }
            }
            Deque<Integer> tmpXQue = xQue;
            Deque<Integer> tmpYQue = yQue;
            xQue = nextXQue;
            yQue = nextYQue;
            nextXQue = tmpXQue;
            nextYQue = tmpYQue;
        }
        if (!isPossible) System.out.println("impossible");
    }