Rite Aid trims losses as loyalty program, new formats drive same-store sales