A major purpose of both the Chinese Exclusion Act and the Gentlemen's Agreement with Japan was to