Unsatisfying

Given 2-SAT clauses, find the minimum number of clauses of the form (p_a OR p_b) to add so the whole formula becomes unsatisfiable, or -1.

Medium7GraphDFSGreedyImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

A computer scientist usually tries to satisfy a set of constraints. This time you do the opposite and make a list of logical statements unsatisfiable.

You are given a list of logical statements of the following form:

p1p2,¬p2p3,p3¬p4.p_1 \lor p_2, \qquad \neg p_2 \lor p_3, \qquad p_3 \lor \neg p_4.

Each pip_i is a proposition that is either true or false. The disjunction operator \lor is read as logical OR. The symbol ¬\neg is negation, which flips the value of the proposition that follows it from true to false and from false to true.

To satisfy a list of logical statements, you must assign true or false to each proposition so that every disjunction in the list evaluates to true.

Your task is to add disjunctions to the list so that the whole list becomes unsatisfiable. The disjunctions you add cannot use the negation symbol.

Every disjunction, both the given ones and the ones you add, has exactly two terms.

Input

The first line contains two integers nn and mm separated by a space (1n,m20001 \le n, m \le 2000). Here nn is the number of propositions and mm is the number of disjunctions.

Each of the next mm lines contains two integers aia_i and bib_i separated by a space (1ai,bin1 \le |a_i|, |b_i| \le n), describing the two propositions of the ii-th disjunction. A positive aia_i means the proposition paip_{a_i}, and a negative aia_i means the negated proposition ¬pai\neg p_{|a_i|}. Read bib_i the same way.

The second sample input corresponds to the following list of logical statements:

p1p2,¬p1¬p3,¬p2p3,p3¬p4,¬p2¬p3.p_1 \lor p_2, \quad \neg p_1 \lor \neg p_3, \quad \neg p_2 \lor p_3, \quad p_3 \lor \neg p_4, \quad \neg p_2 \lor \neg p_3.

Output

Print on a single line one integer, the minimum number of disjunctions you must add to make the list unsatisfiable. If the list cannot be made unsatisfiable, print 1-1 instead. Each disjunction you add consists of two propositions, the two propositions do not have to be distinct, and neither of them may be negated.

Hint

In the second sample, adding the disjunction p2p2p_2 \lor p_2 makes the list unsatisfiable.