1711. Wavel Sequence

时间限制 2000 ms   内存限制 512 MB

Have you ever seen the wave? It's a wonderful view of nature. Little Q is attracted to such wonderful thing, he even likes everything that looks like wave. Formally, he defines a sequence $a_1,a_2,...,a_n$ as ''wavel'' if and only if $a_1a_3a_5

20170803195351_68470.jpg
Picture from Wikimedia Commons


Now given two sequences $a_1,a_2,...,a_n$ and $b_1,b_2,...,b_m$, Little Q wants to find two sequences $f_1,f_2,...,f_k(1\leq f_i\leq n,f_i
Moreover, Little Q is wondering how many such two sequences $f$ and $g$ he can find. Please write a program to help him figure out the answer.{i+1})$>$

输入数据

The first line of the input contains an integer $T(1\leq T\leq15)$, denoting the number of test cases.

In each test case, there are $2$ integers $n,m(1\leq n,m\leq 2000)$ in the first line, denoting the length of $a$ and $b$.

In the next line, there are $n$ integers $a_1,a_2,...,a_n(1\leq a_i\leq 2000)$, denoting the sequence $a$.

Then in the next line, there are $m$ integers $b_1,b_2,...,b_m(1\leq b_i\leq 2000)$, denoting the sequence $b$.

输出数据

For each test case, print a single line containing an integer, denoting the answer. Since the answer may be very large, please print the answer modulo $998244353$.

样例输入

复制
1
3 5
1 5 3
4 1 1 5 3 \n
 · \n
 · · \n
 · · · · \n

样例输出

复制
10
  \n

样例说明


20170803200253_11535.png


提交

请先 登录

Source

2017 Multi-University Training Contest - Team 4

© 2025 FAQs Contact About