Pizza
시간 제한2초메모리 제한512 MB
n개의 재료로 만들 수 있는 부분집합 중, m명의 친구가 각자 원하는 조건을 하나 이상 만족하는 경우의 수를 998244353으로 나눈 나머지로 구한다.
문제
Vasya is going to bake a pizza for friends. There are 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 possible pizza recipes.
Not just any pizza will make Vasya's friends happy, though. Every friends prepared a wish list of the form "ingredient should be included into the pizza" or "ingredient 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 .
입력
The first line of the input contains two integers and --- the number of ingredients and the number of Vasya's friends, respectively (, ).
Each of the next lines corresponds to one of Vasya's friend and contains an integer --- the number of wishes on the wish list, followed by integers --- the description of wishes on the list (, , ). If is positive, the -th friend has a wish "ingredient should be included into the pizza", if it's negative, the -th friend has a wish "ingredient 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 .
힌트
In the first example, the following sets of ingredients will make all friends happy: , , , , .
In the second example, ingredient shouldn't be included into the pizza, while all the other ingredients may be either included or not. The answer is equal to modulo .