Pizza

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Vasya is going to bake a pizza for mm friends. There are nn additional ingredients at Vasya's disposal, each of which can either be put into pizza or not. Vasya may use all ingredients or even prepare a pizza without additional ingredients at all. Thus, there are 2n2^n possible pizza recipes.

Not just any pizza will make Vasya's friends happy, though. Every friends prepared a wish list of the form "ingredient tt should be included into the pizza" or "ingredient tt shouldn't be included into the pizza". Vasya's friends aren't too choosy: any pizza which has at least one of friend's wishes satisfied will make the friend happy.

Calculate the number of ways Vasya can bake the pizza to make all friends happy. Since this number may be too large, output it modulo 998244353998244353.

입력

The first line of the input contains two integers nn and mm --- the number of ingredients and the number of Vasya's friends, respectively (1n10001 \le n \le 1000, 1m201 \le m \le 20).

Each of the next mm lines corresponds to one of Vasya's friend and contains an integer a_ia\_i --- the number of wishes on the wish list, followed by a_ia\_i integers b_i,jb\_{i,j} --- the description of wishes on the list (1a_i1001 \le a\_i \le 100, nb_i,jn-n \le b\_{i,j} \le n, b_i,j0b\_{i,j} \neq 0). If b_i,jb\_{i,j} is positive, the ii-th friend has a wish "ingredient b_i,jb\_{i,j} should be included into the pizza", if it's negative, the ii-th friend has a wish "ingredient b_i,j-b\_{i,j} shouldn't be included into the pizza".

Every ingredient occurs at most once in every list.

출력

Output the number of different pizzas making all friends happy, modulo 998244353998244353.

힌트

In the first example, the following sets of ingredients will make all friends happy: (1)(1), (3)(3), (1,3)(1, 3), (1,4)(1, 4), (1,3,4)(1, 3, 4).

In the second example, ingredient 4242 shouldn't be included into the pizza, while all the other ingredients may be either included or not. The answer is equal to 2672^{67} modulo 998244353998244353.