2019-2020 Azerbaijan Finals, June 17
Virologist Abutalib continues his mathematical calculations. He is looking for effective ways to detect positive or negative tests for coronavirus. Abutalib has tests for coronavirus numbered from a to b. In the course of his calculations, he found out that positive tests satisfy certain conditions. Thus, the test for coronavirus is positive if the serial number of the test is divided by k numbers previously determined by Abutalib, and at the same time, it is not divided by m numbers also previously determined by Abutalib. You should help Abutalib to find how many tests from a to b are positive.
First line contains numbers a and b (1 ≤ a ≤ b ≤
1018 ). Second line contains numbers k and m (0 ≤ k , m ≤ 20). Third line contains k integers
xi (1 ≤
1018 ) - numbers that must divide the positive test. Fourth line contains m integers
yi (1 ≤
1018 ) - numbers that must not divide the positive test.
Print the number of positive tests from a to b.
5 15 1 1 2 4
5 15 0 2 3 5
1 100000 0 0