P16348 [CodeChef] LTM40AB
普及
题目描述

Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.

Chef likes inequalities. Please help him to solve next one.
Given four integers a, b, c, d. Find number of solutions x < y, where a ≤ x ≤ b and c ≤ y ≤ d and x, y integers.

------ Input ------

The first line contains an integer T denoting number of tests.
First line of each test case contains four positive integer numbers a, b, c and d.

------ Output ------

For each test case, output a single number each in separate line denoting number of integer solutions as asked in the problem.

------ Constraints ------

$1 ≤ T ≤ 20 $
$1 ≤ a, b, c, d ≤ 10^{6}$

------ Subtasks ------

$Subtask #1: (30 points) 1 ≤ a, b, c, d ≤ 10^{3}.$
$Subtask #2: (70 points) Original constraints.$

----- Sample Input 1 ------
1
2 3 3 4
----- Sample Output 1 ------
3
----- explanation 1 ------

----- Sample Input 2 ------
1
2 999999 1 1000000
----- Sample Output 2 ------
499998500001
----- explanation 2 ------

输入格式

见题面

输出格式

见题面

样例输入
1 2 3 3 4
样例输出
3