Endogenous formation of coalitions in oligopoly