/**
 * Given two lists, modify the elements of the first list using slicing and iterate over the second list to perform specific actions.
 */
import kotlin.random.Random


fun modifyElementsAndIterate(list1: MutableList<Int>, list2: MutableList<Int>): Pair<List<Int>, List<Int>> {

    list1.subList(1, 4).apply {
        this[0] = Random.nextInt(1, 11)
        this[1] = Random.nextInt(1, 11)
        this[2] = Random.nextInt(1, 11)
    }
    list1.subList(list1.size - 3, list1.size).clear()
    list1.addAll(list2.subList(list2.size - 3, list2.size))

    list2.replaceAll { element ->
        if (element % 2 == 0) {
            element * 2
        } else {
            element + 1
        }
    }

    return Pair(list1, list2)
}
import kotlin.random.Random

/**
 * Given two lists, modify the elements of the first list using slicing and iterate over the second list to perform specific actions.
 */
fun modifyElementsAndIterate(list1: MutableList<Int>, list2: MutableList<Int>): Pair<List<Int>, List<Int>> {
import kotlin.random.Random

/**
 * Given two lists, modify the elements of the first list using slicing and iterate over the second list to perform specific actions.
 */
fun modifyElementsAndIterate(list1: MutableList<Int>, list2: MutableList<Int>): Pair<List<Int>, List<Int>> {

    list1.subList(1, 4).apply {
        this[0] = Random.nextInt(1, 11)
        this[1] = Random.nextInt(1, 11)
        this[2] = Random.nextInt(1, 11)
    }
    list1.subList(list1.size - 3, list1.size).clear()
    list1.addAll(list2.subList(list2.size - 3, list2.size))

    list2.replaceAll { element ->
        if (element % 2 == 0) {
            element * 2
        } else {
            element + 1
        }
    }

    return Pair(list1, list2)
}