Python based implementation of https://mediawiki.org/wiki/User:Yuvipanda/G2G