Pion production from deuterium bombarded with polarized protons of 277 and 500 MeV