아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Pizza

시간 제한2초메모리 제한512 MB

요약
n개의 재료로 만들 수 있는 부분집합 중, m명의 친구가 각자 원하는 조건을 하나 이상 만족하는 경우의 수를 998244353으로 나눈 나머지로 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 비트 연산, 조합론, 수학
정답자
아직 제출이 없습니다

문제

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 (1≤n≤10001 \le n \le 1000, 1≤m≤201 \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 (1≤a_i≤1001 \le a\_i \le 100, −n≤b_i,j≤n-n \le b\_{i,j} \le n, b_i,j≠0b\_{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.

예제2

  1. 예제 1

    입력
    4 3
    2 1 3
    3 2 -4 1
    1 -2
    
    예상 출력
    5
    
  2. 예제 2

    입력
    68 1
    1 -42
    
    예상 출력
    468704809