Massachusetts Nonresident question

I worked in Massachusetts for five months last year while living in New Hampshire, then moved to Maine and started working in Maine. Should I be apportioning my wages for my MA taxes, and if so, how do I do it?

 

I have 3 W2s, one in Mass and two in Maine. Do I separate it by working days? Do I select "Other" on the two Maine W2s and 100% Mass income on the Mass W2? Am I supposed to do this entirely differently? Whatever I do doesn't seem to be working.