Source: https://www.web.stanford.edu/~laurik/publications/pmatch.pdf