The highlanders say there are three kinds of truth: the holy truth, also the truth, and the plain truth. Logicians in Byteland decided to check the saying by measuring how true a formula written in clausal form really is.
The value of a formula depends on the values given to its variables. A function that assigns a value to every variable is called a valuation and is written as f:{1,2,…,n}→{true,false}, where f(i) is the value given to xi. There are 2n valuations in total, and once a valuation is fixed the formula is either true or false.
A formula that is true under every valuation is a tautology, and a formula that is false under every valuation is a contradiction. Most formulas are neither, so their value really depends on the valuation. How true a formula is can therefore be written as a fraction between 0 and 1:
2nnumber of valuations under which the formula is true
The value 1 belongs to tautologies and the value 0 to contradictions.
For example, (x1∧¬x1)∨(¬x2∧¬x3)∨(x3∧x2) is true under four of the eight valuations, so its truth fraction is 1/2.
Given a formula, compute its truth fraction exactly.
The first line contains the integers n and m separated by a single space (1≤n≤20, 1≤m≤100). The variables that may appear in the formula are x1,x2,…,xn, and the formula consists of m clauses.
Each of the next m lines describes one clause and holds integers separated by single spaces. The first integer l on the line is the number of literals in that clause, 1≤l≤n. It is followed by l integers that describe the literals in order. All of them are nonzero and lie between −n and n. The integer i stands for xi and the integer −i stands for ¬xi (1≤i≤n).
The same variable may appear several times in one clause, and a variable may appear together with its own negation. A clause that holds both a variable and its negation is false under every valuation.
Print one line with the exact truth fraction of the formula. The fraction has denominator 2n, so it can be written exactly as a terminating decimal with at most n digits after the decimal point. Do not print trailing zeros after the decimal point.
Print 0 if the formula is false under every valuation and 1 if it is true under every valuation. In all remaining cases the answer is greater than 0 and smaller than 1, so print a decimal that starts with 0..