Rosetta Problems

Text Input on a Smart TV

https://atcoder.jp/contests/awc0162/tasks/awc0162_d