How was the church politically powerful during the middle ages