To store points collected by Person P2 when he / she begins journey from start and from end .
let P2S = new Array ( M + 2 ) ; let P2E = new Array ( M + 2 ) ; for ( let i = 0 ; i < M + 2 ; i ++ ) { P1S [ i ] = new Array ( N + 2 ) ; P1E [ i ] = new Array ( N + 2 ) ; P2S [ i ] = new Array ( N + 2 ) ; P2E [ i ] = new Array ( N + 2 ) ; for ( let j = 0 ; j < N + 2 ; j ++ ) { P1S [ i ] [ j ] = 0 ; P1E [ i ] [ j ] = 0 ; P2S [ i ] [ j ] = 0 ; P2E [ i ] [ j ] = 0 ; } }