Wesley's Anger Contest Reject 2 - 🥕suba

View as PDF

Points: 3
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Recently, Tesley has been learning about polynomials, and since her friends always throw around the term "🥕suba", she would like to learn more about it.

Tesley wants to know how many terms the resulting polynomial will have if she multiplies two polynomials that have and terms, respectively. A polynomial is an expression consisting of variables and coefficients, but to keep things simple, Tesley will only deal with polynomials where the coefficient of each term is , and the polynomial will be the lowest degree possible while ensuring that it has the number of terms specified.

For example is a valid polynomial for terms, while and are not valid polynomials for and terms respectively.

Can you help Tesley determine the number of terms in the resulting polynomial after they are multiplied together?

Constraints

For this problem, you will be required to pass all the samples in order to receive points.

Input Specification

The first line will contain , the number of test cases.

The second line will contain two space-separated integers and , the number of terms in the first and second polynomials, respectively.

Output Specification

This problem is graded with an identical checker. This includes whitespace characters. Ensure that every line of output is terminated with a \n character and that there are no trailing spaces.

Output lines. On the line, output the number of terms in the resulting polynomial for the test case.

Sample Input 1

2
2 2
3 4

Sample Output 1

3
6

Sample Explanation 1

For the first test case,

There are two polynomials with two terms, and , when multiplied together becomes .

For the second test case,

There are two polynomials with degree and , and , when multiplied together becomes .