# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

You will be given three pairs of integers, which denotes the starting and ending time in seconds of three classes.

The task is very simple. You have to assign three classrooms for the classes and find the total class time. Class time is when at least one class is running.

The first line will contain a positive integer **T** (1 ≤ T ≤ 100), denoting the number of test cases.

Each of the next T lines will contain 6 space separated positive integers denoting **a _{1}**,

Integers a_{i} and b_{i} are the starting and finishing time respectively of the i’th class.

For each test case print the time required.

Input | Output |
---|---|

1 1 2 3 4 5 6 | 6 |

Here the first class is from 1 to 2 inclusive, so the class time is 2. The second class is from 3 to 4 inclusive, so the class time is 2 and it is the same for the third one. |

53% Solution Ratio

AashiqEarliest,

kamrul_ashrafFastest, 0.0s

Nasif_44thLightest, 0 B

mashfiqur404Shortest, 321B

Login to submit