Source: http://perso.utinam.cnrs.fr/~viennot/doc/TD_MQ.pdf