It all began with just one case of Covid-19, but China's capital is not taking any chances as it screens arrivals from around the country and turns away those deemed to pose a risk.
Set to host a meeting of the Communist Party's elite next month and the Winter Olympics in February, the stakes for Beijing are high, should any cases slip through the net.
A man surnamed Xu travelled to Beijing by train on October 15 from his hometown Wuwei, in the northwest, occupying a bunk near a man surnamed Ai who later tested positive for the coronavirus. Ai had previously shared a car with an infected Shanghai couple during their road trip around the north.
Do you have questions about the biggest topics and trends from around the world? Get the answers with SCMP Knowledge, our new platform of curated content with explainers, FAQs, analyses and infographics brought to you by our award-winning team.
Xu tested positive for the Delta variant three days after his trip, and by last Saturday his wife and son had been confirmed positive, too.
He and his wife had 114 close contacts, who were themselves in contact with a total of 197 others in southern Beijing's Fengtai district, where they live - one of three districts in which cases were concentrated, the district government said. The son had 26 close contacts, who were in contact with a further 84.
The city will refuse entry to those who have travelled to counties with infections in the previous 14 days, even if they are Beijing residents, police said on Sunday. Anyone seeking to enter the capital needed to show a negative test from within the previous two days, and be monitored for 14 days after arrival.
Beijing has also postponed its annual marathon, and closed amusement parks and chess and mahjong parlours as it tries to contain one of China's more widespread outbreaks of recent months.
The capital accounted for two of the 35 new symptomatic local cases reported nationwide on Sunday, the National Health Commission said on Monday. Three asymptomatic local cases were also found, but China does not include those in its official tally.
The outbreak, which has expanded to 11 provinces and municipalities, was traced to the couple's road trip, involving seven retirees who travelled to Gansu and Inner Mongolia autonomous region.
At least 20 cases have sprung from an Inner Mongolia restaurant at which the group dined. More than 400 travellers were unable to leave Lanzhou, in Gansu, while awaiting Covid-19 test results, a government spokesman said.
Two other road trips were also involved, the Beijing municipal government said on Monday. A group of five, who later tested positive, failed to inform local authorities of their return to the capital and had a combined 1,534 close contacts. Another group of four were in home quarantine after they returned to Beijing and one of their 310 close contacts tested positive.
"We must speed up transmission source tracing and identify high-risk persons immediately and deploy lockdowns, preventing infections outside controlled areas," said Beijing's Covid-19 response unit, led by the capital's Communist Party chief Cai Qi, on Sunday.
"Whenever there is an infected person, their residence, workplace and any venue they have been to should be closed immediately."
Beijing citizens were on high alert, with the outbreak hitting close to home.
"Knowing there's an outbreak is one thing; witnessing a neighbourhood being cordoned off is another," said Huang Shuang, who works for a delivery company.
The 35-year-old is getting nervous because confirmed cases were reported in a residential building less than 500 metres (1,640 feet) from her home in Fengtai.
Ground-floor shops and restaurants that Huang frequented were closed. A dozen security guards sealed off her neighbourhood with steel fences, with non-residents barred.
Already used to tight control measures, she had bought cooking oil, rice and instant noodles. "Given that Beijing is quite experienced in handling outbreaks, I'm not worried that stores will run out of daily necessities," she said.
Steve Mao, a programmer in the northern Changping district - another area with new cases - bought fruit and vegetables, finding plentiful supply.
"There's no panic buying," the 42-year-old said. "After all, we are used to the tight control mode when there's an outbreak. I'm just unhappy that I had to cancel a ski trip to Zhangjiakou."
Set to host several of the Olympic events, Zhangjiakou, 220km (140 miles) northwest of the capital, has required people from Changping to complete 14 days' quarantine on arrival.
Having two close contacts of confirmed cases living in his neighbourhood has rattled Mao. "We are still waiting for the formal information release from the Chinese Centre for Disease Control and Prevention," he said. "Until then, our neighbourhood has banned non-residents from entering."
Despite 20.5 million of its 21.9 million people being fully vaccinated as of Sunday, and fewer new daily cases than in some other areas, the authorities in Beijing have used stricter measures than were enforced elsewhere.
"Beijing has always been stricter with control measures," said Dr Leung Chi-chiu, a respiratory medicine specialist in Hong Kong. "It's the capital, has a large population and holds many international events."
Police were investigating two people for failing to report to the authorities after travelling to Inner Mongolia. The managers of pharmacies that sold them over-the-counter medicines were also investigated for not taking their temperatures before letting them enter.
Copyright (c) 2021. South China Morning Post Publishers Ltd. All rights reserved.