Tudor is managing his Roombas!
Tudor has a total of Roombas which he uses to clean his room. His Roombas each clean parts of a row in his square room, specifically, going from to .
Unfortunately, Tudor also has server cords, each taking up parts of a column in his room, specifically, going from to .
Tudor is going to let his Roombas clean his room, and he wonders: how many times will any Roomba run over a cord? Note that if a Roomba runs over the end of a cord, it still counts.
Subtask 1 [5%]
Subtask 2 [10%]
Subtask 3 [15%]
Subtask 4 [70%]
No additional constraints.
The first line contains integers and .
The next lines each contain space-separated integers and , representing the path of a Roomba.
The next lines each contain space-separated integers and , representing a cord.
On one line, output the number of times any Roomba will run over a cord.
3 3 7 2 7 5 5 7 3 1 7 5 4 5
The Roombas are shown going left to right, and the cords from the bottom up. There are four points of intersection.