Solution to Merchants problem