massachusetts has devised a revenue-sharing program in which each of the state 's 351 cities and towns gets a portion of lottery revenue for discretionary purposes , with the amount based on population .