add solutions of P31 and P39