1, 2, 3, 4
Time limit1sMemory limit256 MB
For each test case, count the distinct sums obtainable from up to a copies of 1, b copies of 2, c copies of 3, and d copies of 4.
Problem
There are copies of , copies of , copies of , and copies of . Write a program that counts the number of distinct values that can be obtained by choosing zero or more of these numbers and adding them together. The sum when nothing is chosen is .
Input
The first line contains the number of test cases .
Each test case is given on one line as , , , and , separated by spaces.
Output
For each test case, print the answer on its own line.