/**
 * This function takes a dictionary of reign periods and a keyword as inputs. It iterates through each reign period
 * in the dictionary and checks if the keyword is present. If the keyword is found, it breaks out of the loop and
 * returns the reign period as a string. If the keyword is not found in any of the reign periods, it returns "Keyword
 * not found."
 *
 * @param reignPeriods A dictionary containing reign periods as keys and corresponding historical information as values.
 * @param keyword The keyword to search for.
 * @return The reign period in which the keyword was found or "Keyword not found" if the keyword is not present.
 */
fun findReignPeriod(reignPeriods: Map<String, List<String>>, keyword: String): String {

    for ((reignPeriod, historicalInfo) in reignPeriods) {  // Iterating through each reign period
        for (info in historicalInfo) {  // Iterating through each historical info in the current reign period
            if (keyword in info) {  // Checking if the keyword is present in the current historical info
                return reignPeriod  // Returning the reign period if keyword is found
            }
        }
    }
    return "Keyword not found"  // Returning if keyword is not found
}
/**
 * This function takes a dictionary of reign periods and a keyword as inputs. It iterates through each reign period
 * in the dictionary and checks if the keyword is present. If the keyword is found, it breaks out of the loop and
 * returns the reign period as a string. If the keyword is not found in any of the reign periods, it returns "Keyword
 * not found."
 *
 * @param reignPeriods A dictionary containing reign periods as keys and corresponding historical information as values.
 * @param keyword The keyword to search for.
 * @return The reign period in which the keyword was found or "Keyword not found" if the keyword is not present.
 */
fun findReignPeriod(reignPeriods: Map<String, List<String>>, keyword: String): String {
/**
 * This function takes a dictionary of reign periods and a keyword as inputs. It iterates through each reign period
 * in the dictionary and checks if the keyword is present. If the keyword is found, it breaks out of the loop and
 * returns the reign period as a string. If the keyword is not found in any of the reign periods, it returns "Keyword
 * not found."
 *
 * @param reignPeriods A dictionary containing reign periods as keys and corresponding historical information as values.
 * @param keyword The keyword to search for.
 * @return The reign period in which the keyword was found or "Keyword not found" if the keyword is not present.
 */
fun findReignPeriod(reignPeriods: Map<String, List<String>>, keyword: String): String {

    for ((reignPeriod, historicalInfo) in reignPeriods) {  // Iterating through each reign period
        for (info in historicalInfo) {  // Iterating through each historical info in the current reign period
            if (keyword in info) {  // Checking if the keyword is present in the current historical info
                return reignPeriod  // Returning the reign period if keyword is found
            }
        }
    }
    return "Keyword not found"  // Returning if keyword is not found
}