Source: https://math.jhu.edu/~jmb/note/twoinv.pdf