Union deal helps A&P get out of bankruptcy