fun main(args:Array<String>?): Unit {
    while(true){
        val (n, q) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && q == 0) return
        val years = Array(n){
            val (eraName, eraBaseYear, westernYear) = readLine()!!.trim().split(' ')
            EraYear(westernYear.toInt() - eraBaseYear.toInt() + 1, eraBaseYear.toInt(), eraName)
        }.sortedBy(EraYear::from).toTypedArray()
        repeat(q){
            val year = readLine()!!.trim().toInt()
            val era = upperBound(years, year){it.from} - 1
            if (era in years.indices && year in years[era].range) println("${years[era].name} ${years[era].asEraYear(year)}")
            else println("Unknown")
        }
    }
}
inline fun <F, T: Comparable<T>> upperBound(array: Array<F>, target: T, selector: (F) -> T): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (selector(array[mid]) <= target) left = mid + 1
        else right = mid
    }
    return right
}
data class EraYear(val from: Int, val length: Int, val name: String) {
    val to: Int
        get() = from + length - 1
    val range: IntRange = from until from + length
    fun asEraYear(year: Int): Int = year - from + 1
}
