How the states got their shapes