https://monkonomon.blogspot.com/2021/07/invert-grid.html