Pakistan retakes key towns in northwest: officials