#1249. 不可做题1

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:传统 评测方式:文本比较
上传者: 匿名

题目描述

You are given two sequences and .

Two sequences and match iff and for every possible pair .

Output the number of subsequences of that match .

输入格式

The first line contains two integers , (, ).

The second line contains integers ().

The third line contains integers ().

输出格式

Output one integer: the answer.

样例

10 5
1 5 5 4 1 4 3 3 4 2
3 4 3 2 1
20

4 2
2 2 2 2
2 2
6

数据范围与提示

Good Luck!