qnli question: In what city was the Mosque-Madrasah of Sultan Hasan? sentence: During the rule of the Fatimid and Mamluk dynasties and their successor states in the medieval Middle East, many of the ruling elite founded madaris through a religious endowment known as the waqf.