Large Hadron Collider. He has recently managed to isolate some samples of antimatter in the LHC and would like to play experiment with them. (Warning: do not try this at home.)
Everyone knows that when matter and antimatter collide, they disappear and release massive amounts of energy in a reaction known as annihilation. If the particles and antiparticles are present in equal amounts, all of them will disappear in the reaction. particles with
antiparticles does not count.
samples of matter and
samples of antimatter, the
-th sample of matter has
particles
, and the
-th sample of antimatter has
antiparticles
. Handling particles is a serious matter, so will not separate any of the particles from a sample. More formally, this means that he can only react a non-empty subset of matter samples with a non-empty subset of antimatter samples.
For fun science, would like you to find out the number of different total annihilation reactions that he can produce with these samples. A reaction is different from another if at least one of the samples used in it is not used in the other.
Constraints
For all test cases, .
Subtask 1 [20%]
Subtask 2 [80%]
Input Specification
The first line of input will contain and
, separated by a space.
The second line will contain space-separated integers,
, indicating the number of particles in each matter sample.
The third line will contain space-separated integers,
, indicating the number of antiparticles in each antimatter sample.
Output Specification
One integer, the number of different total annihilation reactions that
can produce.Sample Input
2 3
1 3
4 4 3
Sample Output
3
Explanation for Sample Output
particles of matter in total from the two samples, which he can use to react with either the first or second sample of antimatter. He can also create a reaction involving the second sample of matter and the third sample of antimatter.
Comments