let steps = [ [-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1] ];
for (let step of steps)
{
let x = m.end.x + step[0];
let y = m.end.y + step[1];
let steps = [ [-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1] ];
for (let step of steps)
{
let x = m.end.x + step[0];
let y = m.end.y + step[1];