NORTH KOREA can be as confusing as it is alarming. It is a hereditary Marxist monarchy. It has the world’s youngest supreme leader and also its oldest. The reigning tyrant, Kim Jong Un, is in his 30s; and his grandfather, Kim Il Sung, is the “eternal president” despite having died in 1994. To celebrate grandpa Kim’s birthday on April 15th, his grandson ordered warplanes to fly past in a formation spelling out his age: 105. He also ordered a gigantic parade, with goose-stepping soldiers and missiles on trucks. A male-voice choir belted out “Peace is guaranteed by our arms”, even as the regime threatens to rain nuclear destruction on its enemies and is building a missile designed to reach the continental United States.

Dealing with the bellicose junior god-king will be one of Donald Trump’s trickiest tasks. It will also be the first big test of how he handles relations with China, which are shifting as the rising superpower challenges the Pax Americana in Asia (see our special report). There are no good options, but arriving at the least-bad ones will require understanding both the regime and the Asian geopolitical jigsaw into which it fits. It will also require patience. Ominously, Mr Trump says he has little when it comes to North Korea, and his vice-president, Mike Pence, says that “all options” are on the table.

Wanting to do something quickly is emotionally appealing. North Korea is a vile, blood-drenched dictatorship where any hint of disloyalty is punishable by gulag or death. Mr Kim has children imprisoned for their parents’ thought-crimes and his own relatives murdered on a whim. The prospect of such a man threatening Los Angeles is harrowing. Yet a pre-emptive strike on North Korea would be reckless beyond belief (see article). Its nuclear devices are hidden, possibly deep underground. Its missiles are dispersed on mobile launchers. Tokyo is just across the Sea of Japan. Seoul, the capital of peaceful, capitalist South Korea, is only a few miles from the border. Northern artillery and conventional missiles could devastate it; a conflict could rapidly turn nuclear and kill millions.

Mr Trump cannot possibly want to start a war. His military actions in Syria and Afghanistan suggest that he is more cautious than his bluster makes him sound. But even creating the impression that he might strike first is dangerous. If Mr Kim were to believe that an American attack is imminent, he might order his own pre-emptive nuclear attack, with disastrous consequences. So Mr Trump should cool his rhetoric immediately.

Dealmaker, meet deal-breaker

For all his eccentricities, Mr Kim is behaving rationally. He watched Muammar Qadaffi of Libya give up his nuclear programme in return for better relations with the West—and end up dead. He sees his nuclear arsenal as a guarantee that his regime, and he, will survive. (Though it would be suicidal for him to use it.) Mr Trump can do little to change his mind. Economic sanctions that harm his people will not spoil his lunch. Cyber-attacks, which may account for the failure of some recent missile launches, can slow but not stop him. America can solve the Korean conundrum only with China’s help.

China has leverage over Mr Kim. It accounts for 85% of North Korea’s foreign trade and could shut off its oil supply. But its interests are not the same as America’s. North Korea is its ally. China’s leaders do not like the Kim regime, but they do not wish to see it collapse and North Korea reunite, German-style, with the democratic South. That, China fears, would mean the loss of a valuable buffer. There are 28,500 American troops stationed in the South; China does not want them on its border.

To contain North Korea—and to conduct a successful foreign policy more broadly—Mr Trump has to learn how to talk to China. His instinct is to do deals. Last week he tweeted that he told Xi Jinping, China’s president, that “a trade deal with the US will be far better for them if they solve the North Korean problem!” Later he explained that his decision not to label China a currency manipulator, as he had threatened, was a quid pro quo for China helping out over North Korea. Dropping the currency threat was the right policy, but Mr Trump’s transactional approach to diplomacy is exactly the wrong one.

China would love to carve up the world bilaterally into spheres of influence, with the great powers dominating their regions and trading favours elsewhere. America has long been the guardian of something different: a rules-based order that applies to every country, big or small, and which has underpinned the relative peace and remarkable growth of the world since 1945. That Mr Trump appears to scorn this rules-based global order is worrying. The world would become a more dangerous place if America started letting China break the rules (for example, in the South China Sea) in exchange for help to resolve whichever issue happens to be in the news. A better response to China’s rise would be for America to strengthen the rules-based order and invite China to join it more actively. Alas, Mr Trump is unlikely to do this.

So the best hope is that he or his diplomats persuade China that it is in its own interest to curb North Korea. And the way to do this is to talk about North Korea itself, not the yuan or American steel jobs.

Three generations of Kims are enough

China does not gain if North Korea destabilises East Asia, or starts a regional arms race that leads Japan and South Korea to build their own nuclear weapons. Mr Trump should reassure his allies in Tokyo and Seoul that they remain under Uncle Sam’s protection. But he should also deal with China’s concerns. To that end, he could make it clear that freezing and then rolling back the North’s nuclear programme is his goal rather than regime change. He could also guarantee that, were the North to collapse into the arms of the South, America would keep its troops south of the current north-south boundary. China hates to admit that the Kim dynasty might not last, but it is rash not to plan for that possibility.

The crucial message for Mr Kim as for his predecessors is that, if the North were to use its nukes, the regime would be obliterated. In the long run, reunification is inevitable and desirable. Meanwhile, the junior god-king can be deterred.