Use inclusion-exclusion to count set covers in O(2^m poly(n))

input is a JSON document of the form {"universe":[e0,e1,...],"sets":[[...],[...],...]}.

universe lists m distinct integer labels that name the universe elements. sets lists n available sets; every set lists element labels drawn from universe. Count the subfamilies of the available sets whose union is exactly the whole universe, then return that count as a canonical decimal string: base ten, no leading zeroes, no sign, and "0" for a count of zero.

Counting rules, which the answer depends on:

  • The available sets are indexed choices. Two available sets with identical contents are two different choices, and a family is a subset of the n indices, so either copy may be selected independently.
  • Each index may be selected at most once, and the empty family selects nothing.
  • An available set may be empty. Selecting it never changes the union, so it freely doubles the number of covering families.
  • Universe labels are identities only. They are encoded as signed 32-bit integers, so a label may be zero or negative, and its sign, order, and gaps carry no meaning. A set may list its labels in any order, and only distinctness and membership affect the count.

The exact count does not fit a binary64 double: with n = 60 available sets the answer can be as large as 2^60 - 1, and 2^60 > 2^53. Return the exact decimal string, for example "787662783788549761", never a rounded floating-point value and never a value reduced modulo anything.

Examples
Input: "{\"universe\":[1,2],\"sets\":[[1],[2],[1,2]]}"
Output: "5"
Hints

Use inclusion-exclusion to count set covers in O(2^m poly(n))

`input` is a JSON document of the form `{"universe":[e0,e1,...],"sets":[[...],[...],...]}`.