

1. No two vehicles can have the same registration number.
2. Two registration numbers are said to be different if they have at least a different character or a digit at the same location. For eg. DL 05 AC 1234 and DL 05 AC 1235 are different, DL 05 AC 1234 and DL 05 AB 1234 are different registration numbers.
3. All the cars will have the same first two characters as they have to be registered in the same state.
4. The numbering of the districts in the state starts from ‘1’ (which will obviously be written as 01 in registration number).
The first line of the input contains an integer 'T' denoting the number of test cases.
The first line of each test case contains a single integer 'districtCount', denoting the number of districts in the state.
The second line of each test case contains four space-separated characters 'ALPHA1', 'ALPHA2', 'ALPHA3' and 'ALPHA4' , denoting the range of the first alphabet and second alphabet of the series. The range for first and the second alphabet will be [ALPHA1, ALPHA2] and [ALPHA3, ALPHA4] respectively.
The third line of each test case contains four space-separated integers 'DIG1', 'DIG2', 'DIG3' and 'DIG4' denoting the range of last 4 digits in the vehicle registration number. The ranges will be [0, DIG1], [0, DIG2], [0, DIG3] and [0, DIG4] respectively.
The only line of output of each test case consists of an integer, the maximum number of vehicles that can be registered in the state.
You don't need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10^4
1 <= Number of districts < 10^2
A <= Range of alphabets <= Z
0 <= Range of digits <= 9
ALPHA1 <= ALPHA2 and ALPHA3 <= ALPHA4
The width of the district column will always be equal to 2.
Time Limit: 1 sec.
Here is the algorithm :