测试数据有多组。
每组的第一行输入一个整数n(n<100),表示要走n步。当n=0时,输入结束。
第二行输入一个包含n个字符的字符串表示每次的移动方向。对于每组样例输出一行,格式为以下三种之一:
The worm ran into itself on move m.
The worm ran off the board on move m.
The worm successfully made all m moves.
m的大小由你的程序决定,我们规定第一次移动为move 1,详情参见样例。18 NWWWWWWWWWWSESSSWS 20 SSSWWNENNNNNWWWWSSSS 30 EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 13 SWWWWWWWWWNEE 0
The worm successfully made all 18 moves. The worm ran into itself on move 9. The worm ran off the board on move 21. The worm successfully made all 13 moves.