What did they consider Hawaii and Alaska to be before they became states who controlled them?

Both were US Territories.