What weapon helped the Ming defeat the Manchus