public void dfs(char[][] board, boolean[][] visited, String str, int i, int j, Trie trie) {
        if (i < 0 || i >= board.length || j < 0 || j >= board[0].length)
            return;
        if (visited[i][j])
            return;
        str += board[i][j];
        if (!trie.startsWith(str))
            return;
        if (trie.search(str)) {
            res.add(str);
        }
        visited[i][j] = true;
        dfs(board, visited, str, i + 1, j, trie);
        dfs(board, visited, str, i - 1, j, trie);
        dfs(board, visited, str, i, j - 1, trie);
        dfs(board, visited, str, i, j + 1, trie);
        visited[i][j] = false;
    }