During the Polish–Lithuanian Commonwealth, the Zaporizhian Cossack state was allied to the Catholic King of Poland, and the Cossacks were often hired as mercenaries. That had a strong impact on the Ukrainian language and led to the establishment of a functioning Ukrainian Greek Catholic Church in 1596 at the Union of Brest. The Ukrainians, however, retained their Orthodox Christian faith and Cyrillic alphabet. During the Russo-Polish War of 1654–1667, the Cossacks were divided into the pro-Polish (Right-bank Ukraine) and pro-Russian (Left-bank Ukraine) factions. Petro Doroshenko, who commanded the army of Right-bank Ukraine, and Pavlo Teteria and Ivan Vyhovsky were open Polonophiles and allied to the Polish king. The Polish influence on Ukraine ended with the partitions of the late 18th century, when the territory of contemporary Ukraine was annexed by the Russian Empire.