2D array for storing the final result
let ans = new Array ( n ) ; for ( var i = 0 ; i < ans . length ; i ++ ) { ans [ i ] = new Array ( 2 ) ; } for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) {