Jon wants to go in birthday party of Arya. But he is busy in finding solution of crazy equations, so he wants your help to solve this problem. Jon has four integers **a, b, c, d **now he wants to calculate how many distinct set of **x, y, z, w **are present such that

a + b - x == a + c - y == c + d - z == b + d - w

**NOTE -**

1<= x, y, z, w<=n where n is a given integer

Two set of x, y, z, w will be different if atleast one value will be different.

**Input**

First line of input contain an integer **T **denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing five space separated integers denoting n, a, b, c, d in order.

**Output**

Print answer for each test case in separate line.

**Constraints**

1

1<=n<=1000000

1<=a, b, c, d <=n

**Example:**

**Input**

1

5 1 2 2 2

**Output:**

4

**Explanation**

Sets of x, y, z, w can be

(1, 1, 2, 2)

(2, 2, 3, 3)

(3, 3, 4, 4)

(4, 4, 5, 5)

Author: rajuknit

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

madhursengar24 | 86 |

PiyushPandey4 | 617 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 448 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.