fun main() {
Task5().run()
}
class Task5 {
fun run() {
val (_, l, r) = readln().split(" ").map { it.toInt() }
val sequence = readln()
val result = maxDifference(sequence, l, r)
if (sequence.length != result.first.joinToString("").length) {
println("NO SOLUTION")
return
}
println(result.second)
println(result.first.size)
println(result.first.joinToString("\n"))
}
private fun maxDifference(a: String, l: Int, r: Int): Pair<List<String>, Int> {
val n = a.length
val words = Array(n + 1) { Pair(emptyList<String>(), 0) }
for (i in l..n) {
for (x in l..r) {
if (i >= x) {
val slice = a.substring(i - x, i)
var maxChar = Int.MIN_VALUE
var minChar = Int.MAX_VALUE
for (char in slice) {
val code = char.code
if (code > maxChar) maxChar = code
if (code < minChar) minChar = code
}
val new = words[i - x].second + (maxChar - minChar)
if (words[i].second <= new) {
val newArr = words[i - x].first.toMutableList()
newArr.add(slice)
words[i] = Pair(newArr, new)
}
}
}
}
return words.last()
}
}