5. On a sheet of paper, 14 parallel lines $L$ and 15 lines $P$ perpendicular to them are drawn. The distances between adjacent lines from $L$ from the first to the last are given: 2;4;6;2;4;6;2;4;6;2;4;6;2. The distances between adjacent lines from $P$ are also known: 3;1;2;6;3;1;2;6;3;1;2;6;3;1. Find the greatest length of the side of a square whose boundaries lie on the lines $L$ and $P$.
5. Solution. We will prove that the maximum length of the side of the square is 40. Calculate the distance from the first to the last line in $P: 3+1+2+6+3+1+2+6+3+1+2+6+3+1=40$. Therefore, the side length of the square cannot be more than 40. On the other hand, in $L$ the distance from the second line to the third line from the end is $4+6+2+4+6+2+4+6+2+4=40$. This means that a square with a side length of 40 exists.