eolymp
bolt
Try our new interface for solving problems
Problems

Silver chain

Silver chain

This is not the time to ask questions! The History Museum in London houses a 19th-century silver chain that belonged to Queen Victoria herself. Johnny English will have to get it to give as a ransom for secret documents. Johnny will be able to get into the museum at night without any problems, but the stolen chain needs to be replaced with something so that the loss is not noticed too quickly. Johnny has another chain with him. He wants to replace the chain in the museum with his own.

The chain in the museum is fixed and represents a closed polygonal line, the links of which are segments. Johnny English's chain, lying on the table in front of him, is also a closed polygonal line, the links of which are segments. Johnny wonders if he can fix his chain in the museum, in place of the stolen one, so that he gets exactly the same polygonal line as the one formed by the chain in the museum. In particular, if the chain in the museum covers one segment several times, then Johnny wants his chain to cover this segment the same number of times. Johnny can bend his chain in arbitrary places, not just at the ends of the links.

Polylines can have self-intersections, links of zero length, and overlapping links.

Input

The first line contains one integer n (3n1000) - the number of vertices of the polyline representing the chain in the museum. The next n lines contain the coordinates of the vertices of the first polyline in the order xi, yi (|xi|, |yi| ≤ * 1000). The next line contains one integer *m (3m1000) - the number of vertices of the polyline representing Johnny's chain. The next m lines contain the coordinates of the vertices of the second polyline in the order xi, yi (|xi|, |yi| ≤ * 1000*).

Output

On a single line print "Yes" if Johnny can fix his chain exactly like the one kept in the museum. And "No" otherwise.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
0 0
1 0
0 1
3
1 1
0 1
1 0
Output example #1
Yes
Input example #2
4
0 0
1 0
1 3
0 3
4
0 0
2 0
2 2
0 2
Output example #2
Yes
Input example #3
5
0 0
1 0
1 1
1 0
1 1
3
0 0
1 0
1 1
Output example #3
No
Source 2018 Цикл Интернет-олимпиад для школьников, первая командная олимпиада сезона, 14 октября, Задача G