/**
 * This function takes in two lists and performs the following operations:
 * 1. Remove any duplicate elements from both lists
 * 2. Append the elements from list2 into list1
 * 3. Return the sorted list1
 */
fun manipulateLists(list1: MutableList<Int>, list2: MutableList<Int>): List<Int> {

    try {
        // Remove duplicate elements from list1
        list1.toSet().toMutableList()

        // Remove duplicate elements from list2
        list2.toSet().toMutableList()

        // Append elements from list2 into list1
        list1.addAll(list2)

        // Sort list1 in ascending order
        list1.sort()

    } catch (e: TypeCastException) {
        println("Invalid argument type. Please provide valid lists as arguments.")
    } catch (e: Exception) {
        println("An error occurred: $e")
    }

    return list1
}
/**
 * This function takes in two lists and performs the following operations:
 * 1. Remove any duplicate elements from both lists
 * 2. Append the elements from list2 into list1
 * 3. Return the sorted list1
 */
fun manipulateLists(list1: MutableList<Int>, list2: MutableList<Int>): List<Int> {
/**
 * This function takes in two lists and performs the following operations:
 * 1. Remove any duplicate elements from both lists
 * 2. Append the elements from list2 into list1
 * 3. Return the sorted list1
 */
fun manipulateLists(list1: MutableList<Int>, list2: MutableList<Int>): List<Int> {

    try {
        // Remove duplicate elements from list1
        list1.toSet().toMutableList()

        // Remove duplicate elements from list2
        list2.toSet().toMutableList()

        // Append elements from list2 into list1
        list1.addAll(list2)

        // Sort list1 in ascending order
        list1.sort()

    } catch (e: TypeCastException) {
        println("Invalid argument type. Please provide valid lists as arguments.")
    } catch (e: Exception) {
        println("An error occurred: $e")
    }

    return list1
}