public int count(String[] field,int dist){
        this.field = field;
        this.dist = dist;
        if (field == null || field.length == 0||dist<0) return 0;

        height = field.length;
        width = field[0].length();
        for (int[] row:grid){
            Arrays.fill(row,0);
        }
        int count = 0;
        for (int i=0;i<height;i++){
            for (int j=0;j<width;j++){
                if(field[i].charAt(j)!='v'||grid[i][j]==1) continue;
                count++;
                dfs(j,i);
            }
        }

        int mod = 1;
        for (int i=1;i<=count;i++){
            mod = (mod<<1)%1000000007;
        }
        mod = (mod-1+1000000007)%1000000007;
        return mod;
    }