To help rare whales, Maine and Massachusetts will spend $27 million on data and gear improvements