This problem will be interesting for those who love to play cricket but others shall also try. I have been experiencing this problem since the start of my cricket journey but never had thought that one day I will have some simulation to solve it :D
In a cricket match when it comes to bowling you need to be very clever in case of field placement. Even if you are clever enough but the real challenge comes when field placement needs to be changed just because the batsman is now left handed instead of right handed or vice versa and in many other cases you can think of. So the challenge here is what should be the minimum movement of players in the field so that the required field placement is achieved.
ASSUMPTIONS: Cricket field is a 2D plane where the distance between two points is Manhattan Distance (Refer to the below link in case of clarification) and the bowling takes place from one end only.At the end of each over the bowler goes to the new bowler's place and this movement is assumed negligible.A bowler can be given overs consecutively.Two players may be present at same positions.There will be negligible movement of players for the first over.
https://xlinux.nist.gov/dads/HTML/manhattanDistance.html
INPUT FORMAT
First line contains two space separated integers N,M i.e no of players fielding in the field(including bowler and the wicket keeper) and no of overs respectively.
Each of the next N lines contains field placement of ith bowler for right handed batsman given by 2*(N-2) integers (excluding ith bowler and the wicket keeper) i.e xi1 yi1 xi2 yi2 ......... xi(N-2) yi(N-2)
Each of the next N lines contains field placement of ith bowler for left handed batsman given by 2*(N-2) integers (excluding ith bowler and the wicket keeper) i.e xi1 yi1 xi2 yi2 ......... xi(N-2) yi(N-2)
Each of the next M lines contains two integers Ai,Bi i.e the Aith bowler will bowl ith over and the batsman on strike is of type Bi where Bi=0 means Right handed and Bi=1 means Left Handed
OUTPUT FORMAT
For each over you need to print the minimum movement of players needed to satisfy the required bowler in a newline.
CONSTRAINTS
SUBTASK 1 (Real World) (50 Points)
SUBTASK 2 (God Level) (50 Points)
Problem Setter-Reshab Gupta