402390: GYM100741 L Basketball

Memory Limit:64 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Basketballtime limit per test0.25 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

The most important part of playing basketball in the yard is to choose two equally strong teams. Otherwise, the game could be ruined because the stronger team could win easily.

However, sometimes the number of players in the team is not so important. Especially, if tall guys are playing with small kids.

There are two teams: Reds and Blues. For each player in the teams we know his skills.

We are interested in how many ways we can choose some players from Reds and some players from Blues, so that the created teams are equally strong. The strength of the team is the sum of the skills of its individual players.

Input

The first line of each test case contains the number of players in Reds n and the number of players in Blues m (1 ≤ n, m) (n + m ≤ 17).

The second line of each test case contains the skills of players in Reds from 1 through n.

The third line of each test case contains the skills of players in Blues from 1 through m.

Skills are integers in the interval [1;100000000].

Output

Output the number of ways of choosing two equally strong teams.

ExamplesInput
1 2
2
1 1
Output
1
Input
1 1
1
2
Output
0

加入题单

上一题 下一题 算法标签: