主页 讨论版 问题 名次 状态 统计

请自觉遵守比赛规则,违者严惩,不接受求情!

问题 I: Insert Orz Pandas

问题 I: Insert Orz Pandas

时间限制:2000 ms 内存限制:128 MB
提交:33 解决:13
[ 提交][ 状态][ 讨论版]

题目描述

Orz panda emotion is a famous emotion in XDU/ACM-ICPC QQ groups.
Big Big Xi loves to create new Orz panda emotions.
Now he has a matrix with n lines and m columns,form n*m cells.
And he wants to insert some small Orz pandas to this matrix to create a big emotion.
In each cell of the matrix,he will determine whether put a small Orz panda or not.
For some reasons,he has some special needs of the emotions:
1.In the ith column,there must be a[i] small Orz pandas. (1<=i<=m)
2.In the ith line,assume the total number of Orz pandas is x, x mod 2 must be b[i]. (1<=i<=n)
For example, if n=2 and m=3,a[1..3]={1,1,1},b[1..2]={1,0}

An adapted answer can be like this:

Now, Big Big Xi wants to know there are how many adapted ways to insert the pandas.

输入

There are multiple test cases (no more than 100,and no more than 10 test cases with large n and m), please process to EOF.

In each test case,there are two numbers N and M at the first line.(0

Thenmlines,the ith line has a number indicates a[i].

And thennlines,the ith line has a number indicates b[i].

输出

One number which is the answer of the question (mod by1e9+7)

样例输入

1 1 1 1 2 3 1 1 1 1 0

样例输出

1 4

提示

[ 提交][ 状态][ 讨论版]
Baidu
map