A distributed message-optimal assignment on rings