#P7840. Heart
Heart
Heart
Problem Description
Notice:Don't output extra spaces at the end of one line. Koishi loves her heart. Koishi's heart are divided into 21 pieces, indexed from to . She has kinds of danmaku, using the -th danmaku needs the help of a subset of her heart pieces and has aggressivity . Suppose is a subset of her danmakus. If for any two different kinds of danmaku , it guarantees , then we call a spellcard(because danmaku in the same spellcard must be released simultaneously, and one piece of heart can only supply one kind of damaku at the same time). The aggressivity of the spellcard is product of aggressivities of all danmakus belongs to . Obviously, using spellcard needs the help of heart pieces. The related pieces subset is . Koishi wants to know some details about her spellcards. She will ask questions, in the -th question, she wants to know the sum of aggressivities of all her spellcard whose , is a subset of heart pieces. You must answer all the questions correctly. modulo 998244353
Input
There are only one test case. First line contains a positive integer , the number of danmakus. The -th line of the following lines contains two non-negative integers , describing the -th danmaku, writing integer as binary string will get the subset The following integer contains a positive , the number of questions. The -th line of the following lines contains a non-negative integer , describing the -th question.
Output
Output lines, and the -th line should contain a non-negative integer as the answer of the -th question
Sample Input
3
1 1
1 2
1 3
3
1
2
3
Sample Output
1
1
2
Source
2020 Multi-University Training Contest 7