NH, if you consider NH your state of residence. The fact that you rent an apartment in MA does not change your state of residence.
According to MA Department of Revenue, the legal residence or domicile is the one an individual regards as his true home or principal residence. An individual cannot choose to make his home one place for the general purposes of life and in another for tax purposes. One's legal residence is usually the place where an individual maintains the most important family, social, economic, political and religious ties.