The Mughal Empire flourished in the 16th and 17th centuries ; the British came to dominate the region in the 18th century .