How was Prussia able to expand successfully during the seventeenth and eighteenth centuries?