Another approach: first the perimeter, recursive call with the inner matrix