South Africa's governing African National Congress (ANC) is faced with a tricky dilemma which will determine the future of the country after it spectacularly lost its parliamentary majority in last week's election.
Having won only 40% of the vote, the ANC needs to find a coalition partner to secure a majority in parliament which will support its choice of a president - unless it tries to go alone with a minority government.
One option would be to strike a deal with the second biggest party, the centre-right Democratic Alliance (DA), which won 22% of the vote.
However, this would be politically risky, as the DA's critics accuse it of trying to protect the economic privileges the country's white minority built up during the racist system of apartheid - a charge the party denies.
Alternatively, the ANC could work with two radical parties that broke away from it - former President Jacob Zuma's uMkhonto weSizwe (MK) party or Julius Malema's Economic Freedom Fighters (EFF).
These three parties share the same constituency, the black majority, and their combined vote comes to 65%. Mr Malema has warned the ANC against forming a coalition that would "reinforce white supremacy" and be a "puppet of a white imperialist agenda".
This was a clear reference to a coalition with the DA, whose policies are diametrically opposed to the ANC's, but they both agree on the need to uphold the constitution that South Africa adopted at the end of apartheid in 1994.
President Cyril Ramaphosa has made it clear that any coalition agreement would have to be within the framework of the current constitution.
One of the big obstacles to a deal is the DA's fierce opposition to the ANC's efforts to create a welfare state - especially a government-funded national health service, which the DA rejects, saying it is too expensive andthreatens the future of the private health sector.
The DA believes in the free market, opposes a minimum wage, and wants to reduce red tape, saying this is the best way to improve the economy and raise living standards for all South Africans.
It is vehemently opposed to the ANC's black economic empowerment policies, seeing them as discriminating against racial minorities while simply leading to the enrichment of the ANC's business cronies.
Denying the allegations, the ANC has resolutely pursued these policies, arguing that they give black people a stake in the economy that they were excluded from during apartheid.
ANC chairman Gwede Mantashe has gone as far as to say the ANC's black empowerment policies are non-negotiable, suggesting that he has ruled out a coalition with the DA.
But, according to some local media, President Ramaphosa is willing to enter into a coalition with the DA, believing that their policy differences could be overcome.
The ANC's other option is to form a coalition with MK, which was the big winner of the election by securing third spot with 15% of the vote in the first election it contested.
But it is demanding a fresh poll, alleging that it got even more votes but the final result was rigged. The electoral commission has rejected the allegation, and MK has not yet presented any evidence for its claim.
The chasm between it and the ANC is wide, wider than with any other party, partly because of the personal animosity between Mr Zuma and Mr Ramaphosa, who ousted him as the country's leader.
As well as demanding a new president, MK wants the constitution to be torn up so that South Africa becomes an "unfettered parliamentary democracy" - something the ANC has ruled out.
At first glance, this also rules out the EFF, as it too is demanding a constitutional amendment so that white-owned land can be expropriated without compensation.
Mr Malema, a former ANC youth leader who was expelled by the party in 2012 for fomenting divisions and bringing the party into disrepute, said the EFF was willing to work with the ANC in a coalition government. However, the party's demand for land expropriation was a "cardinal principle", and it would not join the government if the ANC rejects it.
The ANC and EFF together have 198 seats - just short of the 201 seats needed for a parliamentary majority, so a smaller party would have to be brought into a coalition.
Or they could team up with Mr Zuma's MK, which also supports land expropriation, and says there is a need to distribute farmland on an "equal basis among the farming population".
But to change the constitution, a two-thirds majority is needed and again the ANC, EFF and MK fall just short of the 267 seats needed - they have 256 seats between them.
While the ANC is opposed to constitutional amendments, it accepts that the current land-ownership patterns need to be tackled.
In an interview with South Africa's Sunday Times newspaper, former President Kgalema Motlanthe, a close ally of Mr Ramaphosa, said the "land question" was a "source of national grievance".
His comments suggest there could be room for agreement with the EFF, and possibly even MK, on the issue.
The DA strongly opposes a deal between its three rivals, saying it would be a "Doomsday Coalition" that would turn South Africa into a "Zimbabwe or Venezuela".
"The Doomsday Coalition will plunge this country into ethnic and racial conflict the likes of which it has never witnessed before," the party says.
But some ANC officials hold the opposite view - that stability would be threatened if MK is excluded, given its electoral success, which has made it the largest party in KwaZulu-Natal.
KwaZulu-Natal is South Africa's second-most populous province, and is often described as the economic artery of the nation because of its ports.
It is also politically the most volatile province, with a history of violence - more than 300 people died in riots after Mr Zuma was sent to prison in 2021.
He was convicted of contempt of court for defying an order to co-operate with an official inquiry into corruption during his nine-year presidency, which ended in 2018.
ANC members in KwaZulu-Natal point out that with another court case looming - Mr Zuma is due to stand trial next year on charges of corruption over a 1999 arms deal - there is a real risk of a fresh wave of violence.
They therefore feel some sort of deal needs to be reached with him to draw a line under the past, and to recognise his status as a former president - especially as he has demonstrated that he commands 15% of the national vote.
ANC leaders in Gauteng - South Africa's biggest and rich province - are said to favour a deal with the EFF, but their hand has been considerably weakened by the fact that the two parties do not have enough seats for a parliamentary majority.
That increases the prospect of an ANC-DA coalition, especially as it is favoured by the private sector as the best option to guarantee economic stability and to avoid capital flight.
But South Africa's respected News24 website reports that the ANC is considering the option of forming a minority government, while signing a confidence-and-supply agreement with the DA, and the Inkatha Freedom Party, a mainly black party with support in KwaZulu-Natal, which has 17 seats.
The two would vote with the ANC on crucial issues such as the budget, while the ANC would have to constantly lobby them - or other parties - to support it on other legislation.
This could help the ANC out of its dilemma of choosing a coalition partner, and it may also suit the DA, as a coalition with the ANC could cause it to lose support to parties to its right.
However, there is a risk that a minority government could lead to political instability and "transactional politics" - opposition MPs demanding or being offered bribes to back ANC-sponsored legislation.
It is still too early to say what will happen. All the parties are still considering their options, but many South Africans are hoping that by the time parliament convenes, within a fortnight, there will at least be an outline deal on what the next government will look like.
BBC