//package misc.ukiepc2025 fun main() { val rules = MutableList(readInt()) { val s = readln() if (s[2] == '<') s[0] to s[4] else s[4] to s[0] } val word = readln() val alphabet = List(26) { 'a' + it } val topSort = mutableListOf() repeat(alphabet.size) { val c = (alphabet - topSort.toSet()).firstOrNull { c -> rules.none { it.second == c } } ?: return println("IMPOSSIBLE") topSort.add(c) rules.removeIf { it.first == c || it.second == c } } println(word.toList().sortedBy { topSort.indexOf(it) }.joinToString("")) } private fun readInt() = readln().toInt()