
fun main(args:Array<String>):Unit {
    readLine()!!.toInt()
    val array = readLine()!!.split(' ').map(String::toInt).toIntArray()
    repeat(readLine()!!.toInt()){
        val (b, e) = readLine()!!.split(' ').map(String::toInt)
        for (i in 0 until (e - b) / 2){
            swap(array, b + i, e - 1 - i)
        }
    }
    println(array.joinToString(" "))
}

fun swap(array:IntArray, a:Int, b:Int):Unit {
    val (f, t) = Pair(array[a], array[b])
    array[a] = t
    array[b] = f
}
