Time limit
1s
Memory limit
128 MB
Tae-yang wants to know how many melons grow in a large field at his uncle's house in the countryside. The number K of melons per 1 m^2 is known, so the answer is K times the area of the field.
The field is a rectilinear hexagon shaped like an L, or like that shape rotated by 90, 180, or 270 degrees. Every side runs east-west or north-south. Starting from any vertex, the six side directions and lengths are given in counterclockwise order.
Compute the area of the field and print the total number of melons.
The first line contains K (1 <= K <= 20), the number of melons per 1 m^2. Each of the next six lines contains a side direction and length, in counterclockwise order around the field. Each length is an integer from 1 to 500. Directions are encoded as 1 for east, 2 for west, 3 for south, and 4 for north.
Print the total number of melons growing in the field.