Time limit
1s
Memory limit
128 MB
Junseong has a transparent tape measure with marks at every 1 cm. Six different marks on the tape have colored dots: two red dots, two blue dots, and two yellow dots.
He first folds the tape so that the two red dots meet. Then he folds it so that the two blue dots meet, and finally so that the two yellow dots meet. If the two dots of the next color already meet after an earlier fold, he skips that fold.
When two dots at different current positions must meet, the crease is exactly halfway between them. After the fold, the length of the folded tape is the longer of the two distances from the crease to the current ends of the tape. All later folds use the positions of the dots in this already-folded state.
Given the original tape length and the positions of the colored dots, compute the length of the tape after folding in red, blue, yellow order.
The first line contains the length of the tape. The length is an integer from 10 to 1000, and the unit is not written.
The second line contains the positions of the two red dots. The third line contains the positions of the two blue dots. The fourth line contains the positions of the two yellow dots. Each line contains two integers separated by a space.
All six dot positions are different.
Print the length of the tape after all folds on one line, with exactly one digit after the decimal point. If that digit is 0, print the 0 as well.