Photosynthesis on a Planet Orbiting an M Dwarf: Enhanced Effectiveness during Flares