Around the Track

Limits 1s, 512 MB

In order to compare race tracks, we wish to compute their lengths. A racetrack is strictly two-dimensional (no elevation). It is described by two simple polygons, where one is completely contained inside the other. The track is the region between these two polygons. We define the length of the track as the absolute minimum distance that one needs to travel in order to complete a lap. This could involve traveling on the very edge of the track and arbitrarily sharp cornering.

This is the illustration of sample input number 3 together with the shortest route around the track (dashed).

Input

The input consists of:

For both polygons, the vertices are given in counterclockwise order. The borders of the two polygons do not intersect or touch each other.

Output

Output one line with one floating point number: the length of the race track. Your answer should have an absolute or relative error of at most10-6.

Samples

InputOutput
3
1 1
2 1
1 2
3
0 0
4 0
0 4
3.41421356237309
InputOutput
5
1 1
5 1
5 5
3 3
1 5
4
0 0
6 0
6 6
0 6
16
InputOutput
5
1 1
5 1
5 5
3 3
1 5
5
0 0
6 0
6 6
3 4
0 6
16.4721359549996

This NWERC 2014 problem is licensed under the CC BY-SA 3.0 license.

You can find the original problem on the NWERC website.