7484: Expression

内存限制:128 MB 时间限制:15 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

输入格式

The first line contains an integer T denoting the number of test cases.
For each test case:
The first line contains two integers L and n --- L represents the length of expression string and n represents the number of variables.
The second line contains one string consisting of variables and +, −, ∗, ().
The third line contains n integers, which are the values of xi.
The fourth line contains a integer m denoting the number of query.
The i-th of the following m lines denotes the i-th query,  which contains integers t,i1,i2,⋯,it.
It guarantees that:
T∈[1,20], xi∈[−108,108], L∈[1,105], ∑L∈[1,3×105].
n∈[1,104], ∑n∈[1,3×104], ∑t∈[1,107], ∑m∈[0,8×105].
 

输出格式

For each test, print m+1 lines.

The first line outputs 6 integers: the i-th integer means g(i−1) mod 998244353, i∈[1,6].

For the i-th of the following m lines, print the answer of i-th query mod 998244353.

输入样例 复制

1
11 3
[1]*[2]*[3]
1 2 3
3
1 1
2 1 2
3 1 2 3

输出样例 复制

6 11 12 6 0 0
6
3
1