C. Genshin Master
time limit per test
1 second
memory limit per test
128 megabytes
input
standard input
output
standard output

Yoimiya is playing a rhythm game. There are $$$6$$$ tracks in this game. For any second, if there is a block on a track, the player can gain $$$1$$$ point by pressing the button of that track.

As you can see in the picture, Yoimiya has only one hand to play the game, which means she can press at most $$$5$$$ tracks simultaneously.

Yoimiya playing the rhythm game

Now give you the time intervals of each track that exists a block. Please help Yoimiya calculate the maximum score she can achieve.

Notice that for any time interval, she does NOT have to press it continuously, which is different from the actual game. This means all blocks appear for exactly one second. Interval $$$[l, r]$$$ means there are $$$r - l + 1$$$ blocks on a track from the $$$l$$$-th second to $$$r$$$-th second.

Input

The input consists of $$$6$$$ lines, each line representing a track.

Each line starts with a single integer $$$n$$$ $$$(1 \le n \le 2 \times 10^5)$$$ — the number of time intervals.

Then $$$n$$$ pairs of integers follow ($$$2n$$$ integers in total). Each pair of integers $$$s, t$$$ $$$(1 \le s \le t \le 10^8)$$$ represents a time interval $$$[s, t]$$$ with blocks on this track. It's guaranteed that intervals will not overlap and are sorted in ascending order of $$$s$$$. ($$$t_i < s_j$$$ if and only if $$$i < j$$$)

It is guaranteed that $$$\sum n \le 2 \times 10^5$$$.

Output

Output a single integer in a line — the maximum score Yoimiya can achieve.

Examples
Input
1 1 4
5 1 4 19 19 81 81 114 514 1919 1919810
1 1 4
1 1 4
1 1 4
1 1 4
Output
1918315
Input
1 1 10
1 2 11
1 3 12
1 4 13
1 5 14
1 6 15
Output
55