public boolean exist(char[][] board, String word) {
        if(word == null)
            return false;
        if(board.length==0 || board[0].length==0)
            return false;
        int n = board.length;
        int m = board[0].length;
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                if(dfs(i,j,board,word,0))
                    return true;
        return false;
    }