MA does not have a deduction for contributions.
you add up all your contributions and as they are distributed you subtract that amount.
Until you have used up those contributions, the state taxable amount of the distribution is -0-.
when finaly used up, only the part of distribution in excess of that last bit of contribution is taxable.
As far as I know, tax software won't do this MA book-keeping for you, I could be wrong.
Other states have different rules and the tax software may support that state's rules.