fun main(args:Array<String>?) {
    readLine()!!.toInt()
    val cell = Array(2019) {false}
    val x = readLine()!!.split(" ").map { it.toInt() - 1 }.toMutableList()
    x.forEach { it -> cell[it] = true }
    readLine()!!.toInt()

    for (a in readLine()!!.split(" ").map { it.toInt() - 1 })
        if (x[a] != 2018 && !cell[x[a]+1]) {
            cell[x[a]] = false
            cell[++x[a]] = true
        }
    println(x.joinToString("\n"){ (it+1).toString() })
}
