Who was the most powerful person in the church in medieval times?

In the Early Middle Ages, and in the rest of the middle ages in the West, the Pope was most powerful. In the later middle ages in the East, it was the Patriarch of Constantinople.