The Origins of Alliances