{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eNoticeļ¼Don\u0027t output extra spaces at the end of one line.\u003cbr\u003e\u003cbr\u003eKoishi loves her heart.\u003cbr\u003e\u003cbr\u003eKoishi\u0027s heart are divided into 21 pieces, indexed from $0$ to $20$. She has $n$ kinds of danmaku, using the $i$-th danmaku needs the help of a subset $b_i$ of her heart pieces and has aggressivity $p_i$. Suppose $A$ is a subset of her $n$ danmakus. If for any two different kinds of danmaku $u,v\\in A,u\\neq v$, it guarantees $b_u\\cap b_v\u003d\\emptyset$, then we call $A$ 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 $A$ is product of aggressivities of all danmakus belongs to $A$. Obviously, using spellcard $A$ needs the help of heart pieces. The related pieces subset is $S(A)\u003d\\cup_{u\\in A}b_u$.\u003cbr\u003e\u003cbr\u003eKoishi wants to know some details about her spellcards. She will ask $m$ questions, in the $i$-th question, she wants to know the sum of aggressivities of all her spellcard $A$ whose $S(A)\u003dx_i$, $x_i$ is a subset of heart pieces. You must answer all the questions correctly. modulo 998244353\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are only one test case.\u003cbr\u003e\u003cbr\u003eFirst line contains a positive integer $n(1\\leq n\\leq 10^6)$, the number of danmakus.\u003cbr\u003e\u003cbr\u003eThe $i$-th line of the following $n$ lines contains two non-negative integers $p_i,b_i(0\\leq p_i\u0026lt;998244353,0\\leq b_i\u0026lt;2^{21})$, describing the $i$-th danmaku, writing integer $b_i$ as binary string will get the subset $b_i$\u003cbr\u003e\u003cbr\u003eThe following integer contains a positive $m(1\\leq m\\leq 10^6)$, the number of questions.\u003cbr\u003e\u003cbr\u003eThe $i$-th line of the following $m$ lines contains a non-negative integer $x_i(0\\leq x_i\u0026lt;2^{21})$, describing the $i$-th question.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Output $m$ lines, and the $i$-th line should contain a non-negative integer as the answer of the $i$-th question"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n1 1\r\n1 2\r\n1 3\r\n3\r\n1\r\n2\r\n3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n1\r\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}