UK grocery retailer Wm Morrison Supermarkets has announced that it has agreed to sell nine Safeway stores to rival Sainsbury's.