Coffee recipes
Time: 1 s · Memory: 256 MB
- Prefix sums
Statement
Karen has coffee recipes: recipe recommends brewing at a temperature from to degrees (both inclusive). An integer temperature is admissible if at least recipes recommend it.
Karen asks questions: how many admissible integer temperatures are there from to degrees (inclusive)?
Input format
The first line contains , , (, ). The next lines contain and , then lines contain and (, ).
Output format
For every question print one number on a separate line.
Examples
Input
3 2 4 91 94 92 97 97 99 92 94 93 97 95 96 90 100
Output
3 3 0 4
Input
2 1 1 1 1 200000 200000 90 100
Output
0
Note
Prefix sums in two stages. Difference array: for every recipe , ; the prefix sums of give the number of recipes for every temperature. Then if that number is , and with prefix sums of every question is .
In the first example the admissible temperatures are .
Source: Codeforces, problem 816B.
