402390: GYM100741 L Basketball
Description
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.
InputThe 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].
OutputOutput the number of ways of choosing two equally strong teams.
ExamplesInput1 2Output
2
1 1
1Input
1 1Output
1
2
0