Annihilation of antiprotons at rest in H2 and D2: S versus P state capture