Task: Question Generation
Input (English): Passage: Following a series of invasions beginning shortly after their conquest of England in 1066, the Normans seized much of Wales and established quasi-independent Marcher lordships, owing allegiance to the English crown. However, Welsh principalities such as Gwynedd, Powys and Deheubarth survived and from the end of the 11th century, the Welsh began pushing back the Norman advance. Over the following century the Welsh recovery fluctuated and the English kings, notably Henry II, several times sought to conquer or establish suzerainty over the native Welsh principalities. Nevertheless, by the end of the 12th century the Marcher lordships were reduced to the south and south east of the country. The principality of Gwynedd was the dominant power in Wales in the first half of the 13th century, with Powys and Deheubarth becoming tributary states. Gwynedd's princes now assumed the title "Prince of Wales". But war with England in 1241 and 1245, followed by a dynastic dispute in the succession to the throne, weakened Gwynedd and allowed Henry III to seize Perfeddwlad . However, from 1256 a resurgent Gwynedd under Llywelyn ap Gruffudd  resumed the war with Henry and took back Perfeddwlad. By the Treaty of Montgomery of 1267, peace was restored and, in return for doing homage to the English king, Llywelyn was recognised as Prince of Wales and his re-conquest of Perfeddwlad was accepted by Henry. However, sporadic warfare between Llywelyn and some of the Marcher Lords, such as Gilbert de Clare, Roger Mortimer and Humphrey de Bohun continued.
Output (English): Which happened first, Llywelyn ap Gruffudd taking back Perfeddwlad or the Treaty of Montgomery?