#BS0000057. Lễ hội Snuke (Snuke Festival)
Lễ hội Snuke (Snuke Festival)
Snuke Festival
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
An altar consists of exactly one upper part, one middle part, and one lower part. There are parts in each category, with sizes , , and .
A triple of indices is valid exactly when
Two altars are different if at least one selected part is different. Thus equal-sized parts with different indices are still distinct choices.
Count the number of valid triples.
Input
- The first line contains .
- The second line contains .
- The third line contains .
- The fourth line contains .
Output
Print the number of valid altars.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , .
Example
Input
2
1 5
2 4
3 6
Output
3
Explanation
The three valid choices are , , and .