import java.io.BufferedInputStream; import java.util.*; import java.util.stream.IntStream; public class MetroQuizPabloFast { private final int N, M; private final long ALL; private final List metroLineStops; private final HashMap dp; MetroQuizPabloFast(int N, int M, List metroLineStops) { Objects.requireNonNull(metroLineStops); this.N = N; this.ALL = (1l<(); } double solve(long state) { long asked = (state>>N); long answeredYes = (state)&ALL; var countState = 0;// count.get(state); for (var s : metroLineStops) { if ( (asked&s) == answeredYes) { countState++; } } if (countState <= 1) return 0.0; // done if (countState == 2) return 2.0; // done if (dp.containsKey(state)) { // answer known return dp.get(state); } double current = countState - 1.0; // worst case we eliminate one possibility per question for (int i = 0; i < N && current > 1; i++) { var station = 1l << i; if ((station & asked) > 0) continue; long askedAfter = asked | station; long stateYes = (askedAfter<= current) continue; next += solve(stateNo)/countState; if (next < current ) { current = next; } } current *= countState; dp.put(state,current); return current; } public static void main(String[] args) { Scanner scanner = new Scanner(new BufferedInputStream(System.in)); int N = Integer.parseInt(scanner.nextLine()); int M = Integer.parseInt(scanner.nextLine()); var list = IntStream.range(0,M) .mapToObj(__-> Arrays.stream(scanner.nextLine().split("\s+")) .map(Long::parseLong) .skip(1) // skip number of entries per line .reduce(0l,(acc,element)->acc|(1l<